home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1993-03-18 | 1.0 MB | [ ONLN/HLX2]
open in: MacOS 8.1
extracted
|
Win98
extracted
|
DOS
extracted
browse contents |
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary ).
Confidence Program Detection Match Type Support
10%
dexvert
MacBinary (archive/macBinary)
fallback
Supported
100%
file
MacBinary II, inited, Thu Mar 18 05:31:52 1993, modified Thu Mar 18 05:32:08 1993, creator 'HLX2', type 'ONLN', 1060190 bytes "Drawing in GWorlds for Speed" , at 0x102dde 8153 bytes resource
default (weak)
99%
file
data
default
66%
TrID
SpeedScript document (C64)
default (weak)
33%
TrID
MacBinary 2
default (weak)
100%
siegfried
fmt/1762 MacBinary (II)
default
100%
lsar
MacBinary
default
id metadata key value macFileType [ ONLN] macFileCreator [ HLX2]
hex view +--------+-------------------------+-------------------------+--------+--------+ |00000000| 00 1c 44 72 61 77 69 6e | 67 20 69 6e 20 47 57 6f |..Drawin|g in GWo| |00000010| 72 6c 64 73 20 66 6f 72 | 20 53 70 65 65 64 00 00 |rlds for| Speed..| |00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000040| 00 4f 4e 4c 4e 48 4c 58 | 32 01 00 00 00 00 00 00 |.ONLNHLX|2.......| |00000050| 00 00 00 00 10 2d 5e 00 | 00 1f d9 a7 ce 00 18 a7 |.....-^.|........| |00000060| ce 00 28 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..(.....|........| |00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 de f6 00 00 |........|........| |00000080| 44 52 41 57 49 4e 47 20 | 49 4e 20 47 57 4f 52 4c |DRAWING |IN GWORL| |00000090| 44 53 20 46 4f 52 20 53 | 50 45 45 44 20 41 4e 44 |DS FOR S|PEED AND| |000000a0| 20 56 45 52 53 41 54 49 | 4c 49 54 59 0d 4b 4f 4e | VERSATI|LITY.KON| |000000b0| 53 54 41 4e 54 49 4e 20 | 4f 54 48 4d 45 52 20 41 |STANTIN |OTHMER A| |000000c0| 4e 44 20 4d 49 4b 45 20 | 20 52 45 45 44 0d 33 32 |ND MIKE | REED.32| |000000d0| 2d 42 69 74 20 51 75 69 | 63 6b 44 72 61 77 20 62 |-Bit Qui|ckDraw b| |000000e0| 72 6f 75 67 68 74 20 73 | 79 73 74 65 6d 20 73 75 |rought s|ystem su| |000000f0| 70 70 6f 72 74 20 66 6f | 72 20 6f 66 66 2d 73 63 |pport fo|r off-sc| |00000100| 72 65 65 6e 20 64 72 61 | 77 69 6e 67 20 77 6f 72 |reen dra|wing wor| |00000110| 6c 64 73 20 74 6f 20 74 | 68 65 20 4d 61 63 69 6e |lds to t|he Macin| |00000120| 74 6f 73 68 2c 20 61 6e | 64 20 43 6f 6c 6f 72 20 |tosh, an|d Color | |00000130| 51 75 69 63 6b 44 72 61 | 77 20 63 6f 6e 74 69 6e |QuickDra|w contin| |00000140| 75 65 73 20 74 68 69 73 | 20 73 75 70 70 6f 72 74 |ues this| support| |00000150| 20 69 6e 20 53 79 73 74 | 65 6d 20 37 2e 20 55 73 | in Syst|em 7. Us| |00000160| 69 6e 67 20 63 75 73 74 | 6f 6d 20 64 72 61 77 69 |ing cust|om drawi| |00000170| 6e 67 20 72 6f 75 74 69 | 6e 65 73 20 69 6e 20 6f |ng routi|nes in o| |00000180| 66 66 2d 73 63 72 65 65 | 6e 20 77 6f 72 6c 64 73 |ff-scree|n worlds| |00000190| 20 63 61 6e 20 69 6e 63 | 72 65 61 73 65 20 61 20 | can inc|rease a | |000001a0| 70 72 6f 67 72 61 6d d5 | 73 20 73 70 65 65 64 20 |program.|s speed | |000001b0| 61 6e 64 20 69 6d 61 67 | 65 2d 70 72 6f 63 65 73 |and imag|e-proces| |000001c0| 73 69 6e 67 20 76 65 72 | 73 61 74 69 6c 69 74 79 |sing ver|satility| |000001d0| 2e 20 54 68 69 73 20 61 | 72 74 69 63 6c 65 20 64 |. This a|rticle d| |000001e0| 65 73 63 72 69 62 65 73 | 20 63 75 73 74 6f 6d 20 |escribes| custom | |000001f0| 64 72 61 77 69 6e 67 20 | 72 6f 75 74 69 6e 65 73 |drawing |routines| |00000200| 20 74 68 61 74 20 64 6f | 20 6a 75 73 74 20 74 68 | that do| just th| |00000210| 61 74 2e 0d 49 74 d5 73 | 20 61 20 62 61 73 69 63 |at..It.s| a basic| |00000220| 20 72 75 6c 65 20 6f 66 | 20 4d 61 63 69 6e 74 6f | rule of| Macinto| |00000230| 73 68 20 70 72 6f 67 72 | 61 6d 6d 69 6e 67 20 6e |sh progr|amming n| |00000240| 65 76 65 72 20 74 6f 20 | 77 72 69 74 65 20 61 20 |ever to |write a | |00000250| 64 72 61 77 69 6e 67 20 | 72 6f 75 74 69 6e 65 20 |drawing |routine | |00000260| 74 68 61 74 20 64 72 61 | 77 73 20 64 69 72 65 63 |that dra|ws direc| |00000270| 74 6c 79 20 74 6f 20 74 | 68 65 20 73 63 72 65 65 |tly to t|he scree| |00000280| 6e 2e 20 54 68 65 72 65 | 20 61 72 65 20 74 77 6f |n. There| are two| |00000290| 20 67 6f 6f 64 20 72 65 | 61 73 6f 6e 73 20 66 6f | good re|asons fo| |000002a0| 72 20 74 68 69 73 20 72 | 75 6c 65 2e 20 46 69 72 |r this r|ule. Fir| |000002b0| 73 74 2c 20 6d 75 6c 74 | 69 70 6c 65 20 63 6c 69 |st, mult|iple cli| |000002c0| 65 6e 74 73 20 73 68 61 | 72 65 20 74 68 65 20 73 |ents sha|re the s| |000002d0| 63 72 65 65 6e 2c 20 61 | 6e 64 20 63 75 73 74 6f |creen, a|nd custo| |000002e0| 6d 20 72 6f 75 74 69 6e | 65 73 20 74 68 61 74 20 |m routin|es that | |000002f0| 64 72 61 77 20 64 69 72 | 65 63 74 6c 79 20 74 6f |draw dir|ectly to| |00000300| 20 74 68 65 20 73 63 72 | 65 65 6e 20 6d 61 79 20 | the scr|een may | |00000310| 76 69 6f 6c 61 74 65 20 | 63 6f 6f 70 65 72 61 74 |violate |cooperat| |00000320| 69 6f 6e 20 72 75 6c 65 | 73 20 28 6e 65 77 20 6f |ion rule|s (new o| |00000330| 6e 65 73 20 61 72 65 20 | 62 65 69 6e 67 20 69 6e |nes are |being in| |00000340| 76 65 6e 74 65 64 20 61 | 6c 6c 20 74 68 65 20 74 |vented a|ll the t| |00000350| 69 6d 65 29 2e 20 53 65 | 63 6f 6e 64 2c 20 73 75 |ime). Se|cond, su| |00000360| 70 70 6f 72 74 20 66 6f | 72 20 6e 65 77 20 74 79 |pport fo|r new ty| |00000370| 70 65 73 20 6f 66 20 64 | 69 73 70 6c 61 79 73 20 |pes of d|isplays | |00000380| 6d 61 79 20 62 65 20 61 | 64 64 65 64 20 74 6f 20 |may be a|dded to | |00000390| 51 75 69 63 6b 44 72 61 | 77 20 28 61 73 20 77 61 |QuickDra|w (as wa| |000003a0| 73 20 74 68 65 20 63 61 | 73 65 20 77 69 74 68 20 |s the ca|se with | |000003b0| 33 32 2d 42 69 74 20 51 | 75 69 63 6b 44 72 61 77 |32-Bit Q|uickDraw| |000003c0| 29 2c 20 61 6e 64 20 63 | 75 73 74 6f 6d 20 72 6f |), and c|ustom ro| |000003d0| 75 74 69 6e 65 73 20 74 | 68 61 74 20 64 72 61 77 |utines t|hat draw| |000003e0| 20 64 69 72 65 63 74 6c | 79 20 74 6f 20 74 68 65 | directl|y to the| |000003f0| 20 73 63 72 65 65 6e 20 | 63 65 72 74 61 69 6e 6c | screen |certainl| |00000400| 79 20 77 6f 6e d5 74 20 | 77 6f 72 6b 20 77 68 65 |y won.t |work whe| |00000410| 6e 20 6e 65 77 20 64 69 | 73 70 6c 61 79 20 74 79 |n new di|splay ty| |00000420| 70 65 73 20 61 72 65 20 | 69 6e 74 72 6f 64 75 63 |pes are |introduc| |00000430| 65 64 2e 0d 53 6f 20 69 | 66 20 79 6f 75 72 20 61 |ed..So i|f your a| |00000440| 70 70 6c 69 63 61 74 69 | 6f 6e 20 68 61 73 20 61 |pplicati|on has a| |00000450| 20 64 72 61 77 69 6e 67 | 20 6e 65 65 64 20 74 68 | drawing| need th| |00000460| 61 74 20 51 75 69 63 6b | 44 72 61 77 20 63 61 6e |at Quick|Draw can| |00000470| 6e 6f 74 20 66 75 6c 66 | 69 6c 6c 2c 20 6f 66 66 |not fulf|ill, off| |00000480| 2d 73 63 72 65 65 6e 20 | 64 72 61 77 69 6e 67 20 |-screen |drawing | |00000490| 69 73 20 74 68 65 20 6f | 6e 6c 79 20 77 61 79 20 |is the o|nly way | |000004a0| 74 6f 20 67 6f 2e 20 59 | 6f 75 72 20 61 70 70 6c |to go. Y|our appl| |000004b0| 69 63 61 74 69 6f 6e 20 | 64 72 61 77 73 20 74 6f |ication |draws to| |000004c0| 20 61 6e 20 6f 66 66 2d | 73 63 72 65 65 6e 20 63 | an off-|screen c| |000004d0| 6f 70 79 20 6f 66 20 74 | 68 65 20 61 70 70 6c 69 |opy of t|he appli| |000004e0| 63 61 74 69 6f 6e 20 77 | 69 6e 64 6f 77 2c 20 61 |cation w|indow, a| |000004f0| 6e 64 20 74 68 65 20 6f | 66 66 2d 73 63 72 65 65 |nd the o|ff-scree| |00000500| 6e 20 69 6d 61 67 65 20 | 69 73 20 74 72 61 6e 73 |n image |is trans| |00000510| 66 65 72 72 65 64 20 74 | 6f 20 74 68 65 20 73 63 |ferred t|o the sc| |00000520| 72 65 65 6e 20 77 69 74 | 68 20 51 75 69 63 6b 44 |reen wit|h QuickD| |00000530| 72 61 77 d5 73 20 43 6f | 70 79 42 69 74 73 20 70 |raw.s Co|pyBits p| |00000540| 72 6f 63 65 64 75 72 65 | 2e 20 49 6e 20 74 68 65 |rocedure|. In the| |00000550| 20 6f 66 66 2d 73 63 72 | 65 65 6e 20 65 6e 76 69 | off-scr|een envi| |00000560| 72 6f 6e 6d 65 6e 74 20 | 79 6f 75 72 20 61 70 70 |ronment |your app| |00000570| 6c 69 63 61 74 69 6f 6e | 20 69 73 20 74 68 65 20 |lication| is the | |00000580| 73 6f 6c 65 20 70 72 6f | 70 72 69 65 74 6f 72 2c |sole pro|prietor,| |00000590| 20 61 6e 64 20 73 75 70 | 70 6f 72 74 20 66 6f 72 | and sup|port for| |000005a0| 20 6e 65 77 20 64 69 73 | 70 6c 61 79 73 20 77 69 | new dis|plays wi| |000005b0| 6c 6c 20 6e 6f 74 20 61 | 66 66 65 63 74 20 68 6f |ll not a|ffect ho| |000005c0| 77 20 74 68 65 20 6f 66 | 66 2d 73 63 72 65 65 6e |w the of|f-screen| |000005d0| 20 65 6e 76 69 72 6f 6e | 6d 65 6e 74 20 62 65 68 | environ|ment beh| |000005e0| 61 76 65 73 2e 20 49 6e | 20 61 64 64 69 74 69 6f |aves. In| additio| |000005f0| 6e 2c 20 75 73 69 6e 67 | 20 43 6f 70 79 42 69 74 |n, using| CopyBit| |00000600| 73 20 74 6f 20 74 72 61 | 6e 73 66 65 72 20 61 6e |s to tra|nsfer an| |00000610| 20 6f 66 66 2d 73 63 72 | 65 65 6e 20 69 6d 61 67 | off-scr|een imag| |00000620| 65 20 6f 6e 74 6f 20 74 | 68 65 20 73 63 72 65 65 |e onto t|he scree| |00000630| 6e 20 65 6e 61 62 6c 65 | 73 20 66 61 73 74 20 61 |n enable|s fast a| |00000640| 6e 64 20 73 6d 6f 6f 74 | 68 20 75 70 64 61 74 69 |nd smoot|h updati| |00000650| 6e 67 2e 0d 54 68 65 72 | 65 20 61 72 65 20 61 20 |ng..Ther|e are a | |00000660| 63 6f 75 70 6c 65 20 6f | 66 20 64 69 66 66 65 72 |couple o|f differ| |00000670| 65 6e 74 20 77 61 79 73 | 20 74 6f 20 63 72 65 61 |ent ways| to crea| |00000680| 74 65 20 61 6e 20 6f 66 | 66 2d 73 63 72 65 65 6e |te an of|f-screen| |00000690| 20 64 72 61 77 69 6e 67 | 20 65 6e 76 69 72 6f 6e | drawing| environ| |000006a0| 6d 65 6e 74 2e 20 54 68 | 65 20 6f 6c 64 2d 66 61 |ment. Th|e old-fa| |000006b0| 73 68 69 6f 6e 65 64 20 | 77 61 79 20 69 73 20 74 |shioned |way is t| |000006c0| 6f 20 63 72 65 61 74 65 | 20 69 74 20 62 79 20 68 |o create| it by h| |000006d0| 61 6e 64 2c 20 61 6e 20 | 61 72 64 75 6f 75 73 20 |and, an |arduous | |000006e0| 74 61 73 6b 20 74 68 61 | 74 20 72 65 73 75 6c 74 |task tha|t result| |000006f0| 73 20 69 6e 20 61 6c 6c | 20 74 68 65 20 73 74 72 |s in all| the str| |00000700| 75 63 74 75 72 65 73 20 | 62 65 69 6e 67 20 6b 65 |uctures |being ke| |00000710| 70 74 20 69 6e 20 6d 61 | 69 6e 20 6d 65 6d 6f 72 |pt in ma|in memor| |00000720| 79 2e 20 54 68 65 20 6e | 65 77 2c 20 69 6d 70 72 |y. The n|ew, impr| |00000730| 6f 76 65 64 20 77 61 79 | 20 69 73 20 74 6f 20 63 |oved way| is to c| |00000740| 72 65 61 74 65 20 69 74 | 20 77 69 74 68 20 74 68 |reate it| with th| |00000750| 65 20 4e 65 77 47 57 6f | 72 6c 64 20 63 61 6c 6c |e NewGWo|rld call| |00000760| 20 66 69 72 73 74 20 6d | 61 64 65 20 61 76 61 69 | first m|ade avai| |00000770| 6c 61 62 6c 65 20 62 79 | 20 33 32 2d 42 69 74 20 |lable by| 32-Bit | |00000780| 51 75 69 63 6b 44 72 61 | 77 20 61 6e 64 20 6e 6f |QuickDra|w and no| |00000790| 77 20 73 75 70 70 6f 72 | 74 65 64 20 62 79 20 43 |w suppor|ted by C| |000007a0| 6f 6c 6f 72 20 51 75 69 | 63 6b 44 72 61 77 20 69 |olor Qui|ckDraw i| |000007b0| 6e 20 53 79 73 74 65 6d | 20 37 2e 20 57 68 65 6e |n System| 7. When| |000007c0| 20 74 68 69 73 20 6d 65 | 74 68 6f 64 20 69 73 20 | this me|thod is | |000007d0| 75 73 65 64 2c 20 61 20 | 63 6f 70 79 20 6f 66 20 |used, a |copy of | |000007e0| 74 68 65 20 47 57 6f 72 | 6c 64 20 63 61 6e 20 62 |the GWor|ld can b| |000007f0| 65 20 63 61 63 68 65 64 | 20 6f 6e 20 61 6e 20 61 |e cached| on an a| |00000800| 63 63 65 6c 65 72 61 74 | 6f 72 20 63 61 72 64 2c |ccelerat|or card,| |00000810| 20 74 68 75 73 20 65 6e | 61 62 6c 69 6e 67 20 69 | thus en|abling i| |00000820| 6d 70 72 6f 76 65 64 20 | 70 65 72 66 6f 72 6d 61 |mproved |performa| |00000830| 6e 63 65 20 62 79 20 6d | 69 6e 69 6d 69 7a 69 6e |nce by m|inimizin| |00000840| 67 20 4e 75 42 75 73 aa | 20 74 72 61 66 66 69 63 |g NuBus.| traffic| |00000850| 20 64 75 72 69 6e 67 20 | 64 72 61 77 69 6e 67 20 | during |drawing | |00000860| 6f 70 65 72 61 74 69 6f | 6e 73 2e 20 28 46 6f 72 |operatio|ns. (For| |00000870| 20 61 20 66 75 6c 6c 20 | 63 6f 6d 70 61 72 69 73 | a full |comparis| |00000880| 6f 6e 20 6f 66 20 64 72 | 61 77 69 6e 67 20 6f 70 |on of dr|awing op| |00000890| 65 72 61 74 69 6f 6e 73 | 20 77 69 74 68 20 61 6e |erations| with an| |000008a0| 64 20 77 69 74 68 6f 75 | 74 20 74 68 65 20 75 73 |d withou|t the us| |000008b0| 65 20 6f 66 20 47 57 6f | 72 6c 64 73 2c 20 73 65 |e of GWo|rlds, se| |000008c0| 65 20 d2 4d 61 63 69 6e | 74 6f 73 68 20 44 69 73 |e .Macin|tosh Dis| |000008d0| 70 6c 61 79 20 43 61 72 | 64 20 38 a5 32 34 20 67 |play Car|d 8.24 g| |000008e0| 63 d3 20 69 6e 20 64 65 | 76 65 6c 6f 70 20 49 73 |c. in de|velop Is| |000008f0| 73 75 65 20 33 2e 29 0d | 0d 47 69 76 65 6e 20 74 |sue 3.).|.Given t| |00000900| 68 61 74 20 79 6f 75 20 | 6d 75 73 74 20 63 65 72 |hat you |must cer| |00000910| 74 61 69 6e 6c 79 20 73 | 65 65 20 74 68 65 20 77 |tainly s|ee the w| |00000920| 69 73 64 6f 6d 20 6f 66 | 20 75 73 69 6e 67 20 47 |isdom of| using G| |00000930| 57 6f 72 6c 64 73 20 69 | 6e 20 61 70 70 6c 69 63 |Worlds i|n applic| |00000940| 61 74 69 6f 6e 73 2c 20 | 77 65 d5 6c 6c 20 6e 6f |ations, |we.ll no| |00000950| 77 20 6d 6f 76 65 20 6f | 6e 20 74 6f 20 74 68 65 |w move o|n to the| |00000960| 20 67 6f 6f 64 20 73 74 | 75 66 66 d1 68 6f 77 20 | good st|uff.how | |00000970| 74 6f 20 69 6e 63 72 65 | 61 73 65 20 70 65 72 66 |to incre|ase perf| |00000980| 6f 72 6d 61 6e 63 65 20 | 61 6e 64 20 63 72 65 61 |ormance |and crea| |00000990| 74 65 20 73 6f 6d 65 20 | 69 6e 74 65 72 65 73 74 |te some |interest| |000009a0| 69 6e 67 20 73 70 65 63 | 69 61 6c 20 65 66 66 65 |ing spec|ial effe| |000009b0| 63 74 73 20 77 69 74 68 | 20 63 75 73 74 6f 6d 20 |cts with| custom | |000009c0| 64 72 61 77 69 6e 67 20 | 72 6f 75 74 69 6e 65 73 |drawing |routines| |000009d0| 2e 20 59 6f 75 20 73 68 | 6f 75 6c 64 20 6b 6e 6f |. You sh|ould kno| |000009e0| 77 20 74 68 65 20 62 61 | 73 69 63 73 20 6f 66 20 |w the ba|sics of | |000009f0| 63 72 65 61 74 69 6e 67 | 20 61 6e 64 20 64 69 73 |creating| and dis| |00000a00| 70 6f 73 69 6e 67 20 6f | 66 20 47 57 6f 72 6c 64 |posing o|f GWorld| |00000a10| 73 20 74 6f 20 67 65 74 | 20 74 68 65 20 6d 6f 73 |s to get| the mos| |00000a20| 74 20 66 72 6f 6d 20 74 | 68 69 73 20 61 72 74 69 |t from t|his arti| |00000a30| 63 6c 65 2e 20 49 66 20 | 79 6f 75 20 6e 65 65 64 |cle. If |you need| |00000a40| 20 61 20 72 65 76 69 65 | 77 20 6f 66 20 74 68 65 | a revie|w of the| |00000a50| 73 65 20 62 61 73 69 63 | 73 2c 20 72 65 61 64 20 |se basic|s, read | |00000a60| d2 42 72 61 76 69 6e 67 | 20 4f 66 66 73 63 72 65 |.Braving| Offscre| |00000a70| 65 6e 20 57 6f 72 6c 64 | 73 d3 20 69 6e 20 64 65 |en World|s. in de| |00000a80| 76 65 6c 6f 70 20 49 73 | 73 75 65 20 31 20 6f 72 |velop Is|sue 1 or| |00000a90| 20 73 65 65 20 43 68 61 | 70 74 65 72 20 32 31 20 | see Cha|pter 21 | |00000aa0| 6f 66 20 49 6e 73 69 64 | 65 20 4d 61 63 69 6e 74 |of Insid|e Macint| |00000ab0| 6f 73 68 20 56 6f 6c 75 | 6d 65 20 56 49 2e 0d 43 |osh Volu|me VI..C| |00000ac0| 55 53 54 4f 4d 20 44 52 | 41 57 49 4e 47 20 52 4f |USTOM DR|AWING RO| |00000ad0| 55 54 49 4e 45 53 20 54 | 4f 20 49 4e 43 52 45 41 |UTINES T|O INCREA| |00000ae0| 53 45 20 53 50 45 45 44 | 0d 53 6f 6d 65 74 69 6d |SE SPEED|.Sometim| |00000af0| 65 73 20 51 75 69 63 6b | 44 72 61 77 20 77 6f 72 |es Quick|Draw wor| |00000b00| 6b 73 20 74 6f 6f 20 73 | 6c 6f 77 6c 79 20 66 6f |ks too s|lowly fo| |00000b10| 72 20 73 6f 6d 65 20 6f | 66 20 75 73 2e 20 57 68 |r some o|f us. Wh| |00000b20| 65 72 65 61 73 20 51 75 | 69 63 6b 44 72 61 77 20 |ereas Qu|ickDraw | |00000b30| 6f 66 74 65 6e 20 74 72 | 61 64 65 73 20 70 65 72 |often tr|ades per| |00000b40| 66 6f 72 6d 61 6e 63 65 | 20 66 6f 72 20 66 6c 65 |formance| for fle| |00000b50| 78 69 62 69 6c 69 74 79 | 2c 20 74 68 65 72 65 20 |xibility|, there | |00000b60| 61 72 65 20 74 69 6d 65 | 73 20 77 65 d5 64 20 6a |are time|s we.d j| |00000b70| 75 73 74 20 61 73 20 73 | 6f 6f 6e 20 74 72 61 64 |ust as s|oon trad| |00000b80| 65 20 66 6c 65 78 69 62 | 69 6c 69 74 79 20 66 6f |e flexib|ility fo| |00000b90| 72 20 70 65 72 66 6f 72 | 6d 61 6e 63 65 2e 20 49 |r perfor|mance. I| |00000ba0| 6e 20 74 68 6f 73 65 20 | 63 61 73 65 73 2c 20 77 |n those |cases, w| |00000bb0| 65 20 63 61 6e 20 61 63 | 68 69 65 76 65 20 74 72 |e can ac|hieve tr| |00000bc0| 65 6d 65 6e 64 6f 75 73 | 20 67 61 69 6e 73 20 69 |emendous| gains i| |00000bd0| 6e 20 73 70 65 65 64 20 | 62 79 20 77 72 69 74 69 |n speed |by writi| |00000be0| 6e 67 20 63 75 73 74 6f | 6d 20 72 6f 75 74 69 6e |ng custo|m routin| |00000bf0| 65 73 20 74 6f 20 64 72 | 61 77 20 74 6f 20 6f 66 |es to dr|aw to of| |00000c00| 66 2d 73 63 72 65 65 6e | 20 77 6f 72 6c 64 73 2e |f-screen| worlds.| |00000c10| 20 42 65 66 6f 72 65 20 | 77 72 69 74 69 6e 67 20 | Before |writing | |00000c20| 73 75 63 68 20 61 20 72 | 6f 75 74 69 6e 65 2c 20 |such a r|outine, | |00000c30| 74 68 6f 75 67 68 2c 20 | 77 65 20 6e 65 65 64 20 |though, |we need | |00000c40| 74 6f 20 75 6e 64 65 72 | 73 74 61 6e 64 20 77 68 |to under|stand wh| |00000c50| 61 74 20 73 6c 6f 77 73 | 20 51 75 69 63 6b 44 72 |at slows| QuickDr| |00000c60| 61 77 20 64 6f 77 6e 2e | 0d 57 68 79 20 69 73 20 |aw down.|.Why is | |00000c70| 51 75 69 63 6b 64 72 61 | 77 20 4f 66 74 65 6e 20 |Quickdra|w Often | |00000c80| 53 6f 20 53 6c 6f 77 3f | 0d 4c 65 74 d5 73 20 65 |So Slow?|.Let.s e| |00000c90| 78 61 6d 69 6e 65 20 45 | 72 61 73 65 52 65 63 74 |xamine E|raseRect| |00000ca0| 20 74 6f 20 68 65 6c 70 | 20 75 73 20 75 6e 64 65 | to help| us unde| |00000cb0| 72 73 74 61 6e 64 20 74 | 68 65 20 63 6f 6e 73 69 |rstand t|he consi| |00000cc0| 64 65 72 61 62 6c 65 20 | 6f 76 65 72 68 65 61 64 |derable |overhead| |00000cd0| 20 51 75 69 63 6b 44 72 | 61 77 20 68 61 73 20 74 | QuickDr|aw has t| |00000ce0| 6f 20 64 65 61 6c 20 77 | 69 74 68 20 6a 75 73 74 |o deal w|ith just| |00000cf0| 20 74 6f 20 70 65 72 66 | 6f 72 6d 20 61 20 73 69 | to perf|orm a si| |00000d00| 6d 70 6c 65 20 6f 70 65 | 72 61 74 69 6f 6e 2e 20 |mple ope|ration. | |00000d10| 41 6e 20 45 72 61 73 65 | 52 65 63 74 20 63 61 6c |An Erase|Rect cal| |00000d20| 6c 20 69 73 20 69 73 73 | 75 65 64 20 76 69 61 20 |l is iss|ued via | |00000d30| 61 20 74 72 61 70 2c 20 | 73 6f 20 72 69 67 68 74 |a trap, |so right| |00000d40| 20 6f 66 66 20 74 68 65 | 20 62 61 74 20 77 65 20 | off the| bat we | |00000d50| 69 6e 63 75 72 20 74 68 | 65 20 6f 76 65 72 68 65 |incur th|e overhe| |00000d60| 61 64 20 6f 66 20 74 68 | 65 20 74 72 61 70 20 64 |ad of th|e trap d| |00000d70| 69 73 70 61 74 63 68 65 | 72 2e 20 46 6f 72 20 61 |ispatche|r. For a| |00000d80| 20 63 6f 6d 70 6c 65 78 | 20 6f 70 65 72 61 74 69 | complex| operati| |00000d90| 6f 6e 2c 20 74 68 69 73 | 20 6f 76 65 72 68 65 61 |on, this| overhea| |00000da0| 64 20 69 73 20 72 65 6c | 61 74 69 76 65 6c 79 20 |d is rel|atively | |00000db0| 73 6d 61 6c 6c 2c 20 62 | 75 74 20 66 6f 72 20 61 |small, b|ut for a| |00000dc0| 20 73 69 6d 70 6c 65 20 | 6f 70 65 72 61 74 69 6f | simple |operatio| |00000dd0| 6e 20 70 65 72 66 6f 72 | 6d 65 64 20 72 65 70 65 |n perfor|med repe| |00000de0| 74 69 74 69 76 65 6c 79 | 2c 20 74 68 69 73 20 6f |titively|, this o| |00000df0| 76 65 72 68 65 61 64 20 | 63 61 6e 20 62 65 20 73 |verhead |can be s| |00000e00| 69 67 6e 69 66 69 63 61 | 6e 74 2e 20 49 6e 20 74 |ignifica|nt. In t| |00000e10| 68 65 20 6c 61 74 74 65 | 72 20 63 61 73 65 2c 20 |he latte|r case, | |00000e20| 74 68 65 20 74 72 61 70 | 20 64 69 73 70 61 74 63 |the trap| dispatc| |00000e30| 68 65 72 20 6f 76 65 72 | 68 65 61 64 20 63 61 6e |her over|head can| |00000e40| 20 62 65 20 61 76 6f 69 | 64 65 64 20 62 79 20 63 | be avoi|ded by c| |00000e50| 61 6c 6c 69 6e 67 20 47 | 65 74 54 72 61 70 41 64 |alling G|etTrapAd| |00000e60| 64 72 65 73 73 20 61 6e | 64 20 74 68 65 6e 20 63 |dress an|d then c| |00000e70| 61 6c 6c 69 6e 67 20 74 | 68 65 20 72 6f 75 74 69 |alling t|he routi| |00000e80| 6e 65 20 64 69 72 65 63 | 74 6c 79 2e 20 28 4e 6f |ne direc|tly. (No| |00000e90| 74 65 20 74 68 61 74 20 | 77 69 74 68 20 68 69 67 |te that |with hig| |00000ea0| 68 2d 6c 65 76 65 6c 20 | 72 6f 75 74 69 6e 65 73 |h-level |routines| |00000eb0| 2c 20 73 6f 6d 65 20 74 | 72 61 70 73 20 74 61 6b |, some t|raps tak| |00000ec0| 65 20 61 20 73 65 6c 65 | 63 74 6f 72 2e 29 0d 41 |e a sele|ctor.).A| |00000ed0| 66 74 65 72 20 77 65 d5 | 76 65 20 63 61 6c 6c 65 |fter we.|ve calle| |00000ee0| 64 20 74 68 65 20 72 6f | 75 74 69 6e 65 2c 20 51 |d the ro|utine, Q| |00000ef0| 75 69 63 6b 44 72 61 77 | 20 6d 75 73 74 20 64 6f |uickDraw| must do| |00000f00| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 73 | the fol|lowing s| |00000f10| 65 74 75 70 3a 0d 31 2e | 09 43 68 65 63 6b 20 66 |etup:.1.|.Check f| |00000f20| 6f 72 20 61 20 62 6f 74 | 74 6c 65 6e 65 63 6b 20 |or a bot|tleneck | |00000f30| 70 72 6f 63 65 64 75 72 | 65 20 69 6e 20 74 68 65 |procedur|e in the| |00000f40| 20 63 75 72 72 65 6e 74 | 20 70 6f 72 74 2e 0d 32 | current| port..2| |00000f50| 2e 09 43 68 65 63 6b 20 | 77 68 65 74 68 65 72 20 |..Check |whether | |00000f60| 70 69 63 74 75 72 65 20 | 72 65 63 6f 72 64 69 6e |picture |recordin| |00000f70| 67 20 69 73 20 65 6e 61 | 62 6c 65 64 2e 0d 33 2e |g is ena|bled..3.| |00000f80| 09 43 61 6c 63 75 6c 61 | 74 65 20 74 68 65 20 69 |.Calcula|te the i| |00000f90| 6e 74 65 72 73 65 63 74 | 69 6f 6e 20 6f 66 20 74 |ntersect|ion of t| |00000fa0| 68 65 20 63 6c 69 70 52 | 67 6e 20 61 6e 64 20 74 |he clipR|gn and t| |00000fb0| 68 65 20 76 69 73 52 67 | 6e 20 61 6e 64 20 73 65 |he visRg|n and se| |00000fc0| 65 20 69 66 20 74 68 65 | 20 64 72 61 77 69 6e 67 |e if the| drawing| |00000fd0| 20 77 69 6c 6c 20 62 65 | 20 63 6c 69 70 70 65 64 | will be| clipped| |00000fe0| 20 6f 75 74 2e 0d 34 2e | 09 43 68 65 63 6b 20 77 | out..4.|.Check w| |00000ff0| 68 65 74 68 65 72 20 64 | 72 61 77 69 6e 67 20 69 |hether d|rawing i| |00001000| 73 20 74 6f 20 74 68 65 | 20 73 63 72 65 65 6e 2c |s to the| screen,| |00001010| 20 61 6e 64 20 69 66 20 | 73 6f 20 73 68 69 65 6c | and if |so shiel| |00001020| 64 20 74 68 65 20 63 75 | 72 73 6f 72 20 69 66 20 |d the cu|rsor if | |00001030| 74 68 65 20 64 72 61 77 | 69 6e 67 20 69 6e 74 65 |the draw|ing inte| |00001040| 72 73 65 63 74 73 20 74 | 68 65 20 63 75 72 73 6f |rsects t|he curso| |00001050| 72 20 6c 6f 63 61 74 69 | 6f 6e 2e 0d 35 2e 09 57 |r locati|on..5..W| |00001060| 61 6c 6b 20 74 68 65 20 | 64 65 76 69 63 65 20 6c |alk the |device l| |00001070| 69 73 74 20 61 6e 64 20 | 64 72 61 77 20 74 6f 20 |ist and |draw to | |00001080| 65 61 63 68 20 6d 6f 6e | 69 74 6f 72 20 74 68 61 |each mon|itor tha| |00001090| 74 20 74 68 65 20 63 6c | 69 70 70 65 64 20 72 65 |t the cl|ipped re| |000010a0| 63 74 61 6e 67 6c 65 20 | 69 6e 74 65 72 73 65 63 |ctangle |intersec| |000010b0| 74 73 2e 0d 54 68 65 6e | 20 74 68 65 20 64 72 61 |ts..Then| the dra| |000010c0| 77 69 6e 67 20 74 61 6b | 65 73 20 70 6c 61 63 65 |wing tak|es place| |000010d0| 2c 20 63 6f 6e 73 69 73 | 74 69 6e 67 20 6f 66 20 |, consis|ting of | |000010e0| 74 68 65 73 65 20 73 74 | 65 70 73 3a 0d 36 2e 09 |these st|eps:.6..| |000010f0| 49 66 20 74 68 65 20 70 | 69 78 65 6c 20 6d 61 70 |If the p|ixel map| |00001100| 20 72 65 71 75 69 72 65 | 73 20 33 32 2d 62 69 74 | require|s 32-bit| |00001110| 20 61 64 64 72 65 73 73 | 69 6e 67 2c 20 65 6e 74 | address|ing, ent| |00001120| 65 72 20 33 32 2d 62 69 | 74 20 6d 6f 64 65 2e 0d |er 32-bi|t mode..| |00001130| 37 2e 09 44 65 74 65 72 | 6d 69 6e 65 20 74 68 65 |7..Deter|mine the| |00001140| 20 74 72 61 6e 73 66 65 | 72 20 6d 6f 64 65 20 74 | transfe|r mode t| |00001150| 6f 20 64 72 61 77 20 77 | 69 74 68 2e 0d 38 2e 09 |o draw w|ith..8..| |00001160| 43 6f 6e 76 65 72 74 20 | 74 68 65 20 70 61 74 74 |Convert |the patt| |00001170| 65 72 6e 20 74 6f 20 74 | 68 65 20 63 6f 72 72 65 |ern to t|he corre| |00001180| 63 74 20 64 65 70 74 68 | 20 61 6e 64 20 61 6c 69 |ct depth| and ali| |00001190| 67 6e 6d 65 6e 74 20 66 | 6f 72 20 74 68 69 73 20 |gnment f|or this | |000011a0| 64 72 61 77 69 6e 67 2e | 0d 39 2e 09 44 65 74 65 |drawing.|.9..Dete| |000011b0| 72 6d 69 6e 65 20 68 6f | 77 20 74 6f 20 63 6f 6c |rmine ho|w to col| |000011c0| 6f 72 20 74 68 65 20 70 | 69 78 65 6c 20 70 61 74 |or the p|ixel pat| |000011d0| 74 65 72 6e 20 75 73 69 | 6e 67 20 74 68 65 20 63 |tern usi|ng the c| |000011e0| 6f 6c 6f 72 73 20 66 72 | 6f 6d 20 74 68 65 20 70 |olors fr|om the p| |000011f0| 6f 72 74 2e 0d 0d 31 30 | 2e 09 42 6c 61 73 74 20 |ort...10|..Blast | |00001200| 74 68 65 20 62 69 74 73 | 2e 0d 54 68 65 20 74 65 |the bits|..The te| |00001210| 61 72 64 6f 77 6e 20 63 | 6f 6e 73 69 73 74 73 20 |ardown c|onsists | |00001220| 6f 66 20 74 77 6f 20 73 | 74 65 70 73 3a 0d 31 31 |of two s|teps:.11| |00001230| 2e 09 45 78 69 74 20 33 | 32 2d 62 69 74 20 61 64 |..Exit 3|2-bit ad| |00001240| 64 72 65 73 73 69 6e 67 | 20 6d 6f 64 65 2c 20 69 |dressing| mode, i| |00001250| 66 20 61 70 70 72 6f 70 | 72 69 61 74 65 2e 0d 31 |f approp|riate..1| |00001260| 32 2e 09 55 6e 73 68 69 | 65 6c 64 20 74 68 65 20 |2..Unshi|eld the | |00001270| 63 75 72 73 6f 72 2e 0d | 4e 6f 74 69 63 65 20 74 |cursor..|Notice t| |00001280| 68 61 74 20 74 68 69 73 | 20 6c 69 73 74 20 64 6f |hat this| list do| |00001290| 65 73 6e d5 74 20 69 6e | 63 6c 75 64 65 20 65 72 |esn.t in|clude er| |000012a0| 72 6f 72 20 63 68 65 63 | 6b 69 6e 67 2e 20 51 75 |ror chec|king. Qu| |000012b0| 69 63 6b 44 72 61 77 20 | 64 6f 65 73 20 64 6f 20 |ickDraw |does do | |000012c0| 73 6f 6d 65 20 65 72 72 | 6f 72 20 63 68 65 63 6b |some err|or check| |000012d0| 69 6e 67 2c 20 62 75 74 | 20 72 69 67 6f 72 6f 75 |ing, but| rigorou| |000012e0| 73 20 63 68 65 63 6b 69 | 6e 67 20 73 6c 6f 77 73 |s checki|ng slows| |000012f0| 20 70 65 72 66 6f 72 6d | 61 6e 63 65 20 66 75 72 | perform|ance fur| |00001300| 74 68 65 72 2e 20 57 68 | 69 6c 65 20 6d 61 6e 79 |ther. Wh|ile many| |00001310| 20 6f 66 20 74 68 65 20 | 69 74 65 6d 73 20 6f 6e | of the |items on| |00001320| 20 74 68 69 73 20 6c 69 | 73 74 20 61 72 65 20 61 | this li|st are a| |00001330| 20 73 69 6d 70 6c 65 20 | 63 68 65 63 6b 2c 20 6f | simple |check, o| |00001340| 74 68 65 72 73 20 72 65 | 71 75 69 72 65 20 63 6f |thers re|quire co| |00001350| 6e 73 69 64 65 72 61 62 | 6c 65 20 70 72 6f 63 65 |nsiderab|le proce| |00001360| 73 73 6f 72 20 74 69 6d | 65 2e 20 54 68 65 72 65 |ssor tim|e. There| |00001370| d5 73 20 70 6c 65 6e 74 | 79 20 6f 66 20 72 6f 6f |.s plent|y of roo| |00001380| 6d 20 68 65 72 65 20 66 | 6f 72 20 72 65 64 75 63 |m here f|or reduc| |00001390| 69 6e 67 20 6f 76 65 72 | 68 65 61 64 20 62 79 20 |ing over|head by | |000013a0| 77 72 69 74 69 6e 67 20 | 63 75 73 74 6f 6d 20 72 |writing |custom r| |000013b0| 6f 75 74 69 6e 65 73 2e | 0d 43 75 73 74 6f 6d 20 |outines.|.Custom | |000013c0| 72 6f 75 74 69 6e 65 73 | 20 63 61 6e 20 6f 66 74 |routines| can oft| |000013d0| 65 6e 20 73 6b 69 70 20 | 61 6c 6c 20 62 75 74 20 |en skip |all but | |000013e0| 73 74 65 70 20 31 30 2e | 20 46 6f 72 20 64 72 61 |step 10.| For dra| |000013f0| 77 69 6e 67 20 6f 70 65 | 72 61 74 69 6f 6e 73 20 |wing ope|rations | |00001400| 74 68 61 74 20 73 70 65 | 6e 64 20 74 68 65 20 6d |that spe|nd the m| |00001410| 61 6a 6f 72 69 74 79 20 | 6f 66 20 74 69 6d 65 20 |ajority |of time | |00001420| 69 6e 20 73 74 65 70 20 | 31 30 2c 20 63 75 73 74 |in step |10, cust| |00001430| 6f 6d 20 72 6f 75 74 69 | 6e 65 73 20 63 61 6e d5 |om routi|nes can.| |00001440| 74 20 6f 66 66 65 72 20 | 62 69 67 20 77 69 6e 73 |t offer |big wins| |00001450| 20 69 6e 20 70 65 72 66 | 6f 72 6d 61 6e 63 65 2e | in perf|ormance.| |00001460| 20 42 75 74 20 66 6f 72 | 20 6f 70 65 72 61 74 69 | But for| operati| |00001470| 6f 6e 73 20 74 68 61 74 | 20 73 70 65 6e 64 20 6d |ons that| spend m| |00001480| 6f 73 74 20 6f 66 20 74 | 68 65 20 74 69 6d 65 20 |ost of t|he time | |00001490| 65 6c 73 65 77 68 65 72 | 65 2c 20 63 75 73 74 6f |elsewher|e, custo| |000014a0| 6d 20 72 6f 75 74 69 6e | 65 73 20 63 61 6e 20 61 |m routin|es can a| |000014b0| 63 68 69 65 76 65 20 73 | 69 67 6e 69 66 69 63 61 |chieve s|ignifica| |000014c0| 6e 74 20 70 65 72 66 6f | 72 6d 61 6e 63 65 20 67 |nt perfo|rmance g| |000014d0| 61 69 6e 73 2e 20 0d 46 | 6f 72 20 65 78 61 6d 70 |ains. .F|or examp| |000014e0| 6c 65 2c 20 69 66 20 79 | 6f 75 20 63 6f 70 79 20 |le, if y|ou copy | |000014f0| 61 20 6c 61 72 67 65 20 | 69 6d 61 67 65 20 77 69 |a large |image wi| |00001500| 74 68 20 43 6f 70 79 42 | 69 74 73 20 61 6e 64 20 |th CopyB|its and | |00001510| 74 68 65 20 73 6f 75 72 | 63 65 20 61 6e 64 20 64 |the sour|ce and d| |00001520| 65 73 74 69 6e 61 74 69 | 6f 6e 20 70 69 78 65 6c |estinati|on pixel| |00001530| 20 64 65 70 74 68 73 20 | 61 72 65 20 74 68 65 20 | depths |are the | |00001540| 73 61 6d 65 2c 20 74 68 | 65 20 66 67 43 6f 6c 6f |same, th|e fgColo| |00001550| 72 20 69 73 20 62 6c 61 | 63 6b 20 61 6e 64 20 74 |r is bla|ck and t| |00001560| 68 65 20 62 6b 43 6f 6c | 6f 72 20 69 73 20 77 68 |he bkCol|or is wh| |00001570| 69 74 65 2c 20 74 68 65 | 20 63 6f 6c 6f 72 20 74 |ite, the| color t| |00001580| 61 62 6c 65 73 20 6d 61 | 74 63 68 2c 20 74 68 65 |ables ma|tch, the| |00001590| 20 63 6c 69 70 70 69 6e | 67 20 72 65 67 69 6f 6e | clippin|g region| |000015a0| 73 20 61 72 65 20 72 65 | 63 74 61 6e 67 75 6c 61 |s are re|ctangula| |000015b0| 72 2c 20 61 6e 64 20 74 | 68 65 20 61 6c 69 67 6e |r, and t|he align| |000015c0| 6d 65 6e 74 20 69 73 20 | 74 68 65 20 73 61 6d 65 |ment is |the same| |000015d0| 2c 20 74 68 65 20 6f 70 | 65 72 61 74 69 6f 6e 20 |, the op|eration | |000015e0| 69 73 20 61 6c 72 65 61 | 64 79 20 76 65 72 79 20 |is alrea|dy very | |000015f0| 65 66 66 69 63 69 65 6e | 74 20 73 69 6e 63 65 20 |efficien|t since | |00001600| 74 68 65 20 6d 61 6a 6f | 72 69 74 79 20 6f 66 20 |the majo|rity of | |00001610| 74 69 6d 65 20 69 73 20 | 73 70 65 6e 74 20 6d 6f |time is |spent mo| |00001620| 76 69 6e 67 20 74 68 65 | 20 62 69 74 73 20 72 61 |ving the| bits ra| |00001630| 74 68 65 72 20 74 68 61 | 6e 20 64 6f 69 6e 67 20 |ther tha|n doing | |00001640| 6f 76 65 72 68 65 61 64 | 2e 20 49 6e 20 74 68 69 |overhead|. In thi| |00001650| 73 20 73 69 74 75 61 74 | 69 6f 6e 2c 20 79 6f 75 |s situat|ion, you| |00001660| 20 63 61 6e d5 74 20 68 | 6f 70 65 20 74 6f 20 67 | can.t h|ope to g| |00001670| 61 69 6e 20 73 75 62 73 | 74 61 6e 74 69 61 6c 20 |ain subs|tantial | |00001680| 73 70 65 65 64 20 77 69 | 74 68 20 61 20 63 75 73 |speed wi|th a cus| |00001690| 74 6f 6d 20 64 72 61 77 | 69 6e 67 20 72 6f 75 74 |tom draw|ing rout| |000016a0| 69 6e 65 2e 20 49 6e 20 | 63 6f 6e 74 72 61 73 74 |ine. In |contrast| |000016b0| 2c 20 66 6f 72 20 61 6e | 20 6f 70 65 72 61 74 69 |, for an| operati| |000016c0| 6f 6e 20 73 75 63 68 20 | 61 73 20 73 65 74 74 69 |on such |as setti| |000016d0| 6e 67 20 61 20 73 69 6e | 67 6c 65 20 70 69 78 65 |ng a sin|gle pixe| |000016e0| 6c 2c 20 74 68 65 20 6f | 76 65 72 68 65 61 64 20 |l, the o|verhead | |000016f0| 69 6e 76 6f 6c 76 65 64 | 20 69 6e 20 73 65 74 74 |involved| in sett| |00001700| 69 6e 67 20 75 70 20 74 | 68 65 20 64 72 61 77 69 |ing up t|he drawi| |00001710| 6e 67 20 6f 70 65 72 61 | 74 69 6f 6e 20 65 63 6c |ng opera|tion ecl| |00001720| 69 70 73 65 73 20 74 68 | 65 20 74 69 6d 65 20 61 |ipses th|e time a| |00001730| 63 74 75 61 6c 6c 79 20 | 73 70 65 6e 74 20 64 72 |ctually |spent dr| |00001740| 61 77 69 6e 67 2c 20 73 | 6f 20 74 68 69 73 20 69 |awing, s|o this i| |00001750| 73 20 61 20 63 61 6e 64 | 69 64 61 74 65 20 66 6f |s a cand|idate fo| |00001760| 72 20 61 20 63 75 73 74 | 6f 6d 20 64 72 61 77 69 |r a cust|om drawi| |00001770| 6e 67 20 72 6f 75 74 69 | 6e 65 2e 0d 4f 70 74 69 |ng routi|ne..Opti| |00001780| 6d 69 7a 69 6e 67 20 61 | 20 43 75 73 74 6f 6d 20 |mizing a| Custom | |00001790| 52 6f 75 74 69 6e 65 20 | 74 6f 20 53 65 74 20 41 |Routine |to Set A| |000017a0| 20 53 69 6e 67 6c 65 20 | 50 69 78 65 6c 0d 54 68 | Single |Pixel.Th| |000017b0| 65 20 73 69 6d 70 6c 65 | 73 74 20 64 72 61 77 69 |e simple|st drawi| |000017c0| 6e 67 20 74 6f 20 61 6e | 20 6f 66 66 2d 73 63 72 |ng to an| off-scr| |000017d0| 65 65 6e 20 77 6f 72 6c | 64 20 69 73 20 73 65 74 |een worl|d is set| |000017e0| 74 69 6e 67 20 61 20 73 | 69 6e 67 6c 65 20 70 69 |ting a s|ingle pi| |000017f0| 78 65 6c 2e 20 4c 65 74 | d5 73 20 63 6f 6d 70 61 |xel. Let|.s compa| |00001800| 72 65 20 68 6f 77 20 51 | 75 69 63 6b 44 72 61 77 |re how Q|uickDraw| |00001810| 20 73 65 74 73 20 61 20 | 73 69 6e 67 6c 65 20 70 | sets a |single p| |00001820| 69 78 65 6c 20 77 69 74 | 68 20 68 6f 77 20 61 20 |ixel wit|h how a | |00001830| 63 75 73 74 6f 6d 20 64 | 72 61 77 69 6e 67 20 72 |custom d|rawing r| |00001840| 6f 75 74 69 6e 65 20 6d | 69 67 68 74 20 64 6f 20 |outine m|ight do | |00001850| 69 74 2e 20 46 6f 72 20 | 6f 75 72 20 63 75 73 74 |it. For |our cust| |00001860| 6f 6d 20 72 6f 75 74 69 | 6e 65 2c 20 77 65 d5 6c |om routi|ne, we.l| |00001870| 6c 20 61 73 73 75 6d 65 | 20 74 68 65 20 6f 66 66 |l assume| the off| |00001880| 2d 73 63 72 65 65 6e 20 | 77 6f 72 6c 64 20 69 73 |-screen |world is| |00001890| 20 33 32 20 62 69 74 73 | 20 64 65 65 70 2e 20 54 | 32 bits| deep. T| |000018a0| 68 69 73 20 61 73 73 75 | 6d 70 74 69 6f 6e 20 67 |his assu|mption g| |000018b0| 69 76 65 73 20 75 73 20 | 73 69 67 6e 69 66 69 63 |ives us |signific| |000018c0| 61 6e 74 20 67 61 69 6e | 73 20 69 6e 20 73 70 65 |ant gain|s in spe| |000018d0| 65 64 20 61 6e 64 20 72 | 65 64 75 63 65 73 20 63 |ed and r|educes c| |000018e0| 6f 64 65 20 73 69 7a 65 | 20 61 6e 64 20 63 6f 6d |ode size| and com| |000018f0| 70 6c 65 78 69 74 79 2e | 0d 4f 75 72 20 73 61 6d |plexity.|.Our sam| |00001900| 70 6c 65 20 63 6f 64 65 | 20 69 6e 76 65 72 74 73 |ple code| inverts| |00001910| 20 74 68 65 20 72 65 64 | 20 61 6e 64 20 67 72 65 | the red| and gre| |00001920| 65 6e 20 63 68 61 6e 6e | 65 6c 73 2e 20 46 69 67 |en chann|els. Fig| |00001930| 75 72 65 20 31 20 69 6c | 6c 75 73 74 72 61 74 65 |ure 1 il|lustrate| |00001940| 73 20 74 68 65 20 74 72 | 61 6e 73 66 6f 72 6d 61 |s the tr|ansforma| |00001950| 74 69 6f 6e 20 74 68 69 | 73 20 61 63 63 6f 6d 70 |tion thi|s accomp| |00001960| 6c 69 73 68 65 73 2e 20 | 55 73 69 6e 67 20 51 75 |lishes. |Using Qu| |00001970| 69 63 6b 44 72 61 77 2c | 20 74 68 65 20 63 6f 64 |ickDraw,| the cod| |00001980| 65 20 6c 6f 6f 6b 73 20 | 6c 69 6b 65 20 74 68 69 |e looks |like thi| |00001990| 73 3a 0d 66 6f 72 20 28 | 79 20 3d 20 62 6f 75 6e |s:.for (|y = boun| |000019a0| 64 73 2e 74 6f 70 3b 20 | 79 20 3c 20 62 6f 75 6e |ds.top; |y < boun| |000019b0| 64 73 2e 62 6f 74 74 6f | 6d 3b 20 79 2b 2b 29 0d |ds.botto|m; y++).| |000019c0| 7b 0d 09 66 6f 72 20 28 | 78 20 3d 20 62 6f 75 6e |{..for (|x = boun| |000019d0| 64 73 2e 6c 65 66 74 3b | 20 78 20 3c 20 62 6f 75 |ds.left;| x < bou| |000019e0| 6e 64 73 2e 72 69 67 68 | 74 3b 20 78 2b 2b 29 0d |nds.righ|t; x++).| |000019f0| 09 7b 0d 09 09 47 65 74 | 43 50 69 78 65 6c 28 78 |.{...Get|CPixel(x| |00001a00| 2c 20 79 2c 20 26 6d 79 | 52 47 42 29 3b 0d 09 09 |, y, &my|RGB);...| |00001a10| 6d 79 52 47 42 2e 72 65 | 64 20 5e 3d 20 30 78 46 |myRGB.re|d ^= 0xF| |00001a20| 46 46 46 3b 09 09 2f 2a | 20 49 6e 76 65 72 74 20 |FFF;../*| Invert | |00001a30| 74 68 65 20 72 65 64 20 | 61 6e 64 20 67 72 65 65 |the red |and gree| |00001a40| 6e 20 63 68 61 6e 6e 65 | 6c 73 2e 20 2a 2f 0d 09 |n channe|ls. */..| |00001a50| 09 6d 79 52 47 42 2e 67 | 72 65 65 6e 20 5e 3d 20 |.myRGB.g|reen ^= | |00001a60| 30 78 46 46 46 46 3b 0d | 09 09 53 65 74 43 50 69 |0xFFFF;.|..SetCPi| |00001a70| 78 65 6c 28 78 2c 20 79 | 2c 20 26 6d 79 52 47 42 |xel(x, y|, &myRGB| |00001a80| 29 3b 0d 09 7d 0d 7d 0d | 0d 20 20 20 20 20 20 20 |);..}.}.|. | |00001a90| 20 20 20 20 20 20 20 20 | 20 0d 09 42 65 66 6f 72 | | ..Befor| |00001aa0| 65 20 09 41 66 74 65 72 | 0d 46 69 67 75 72 65 20 |e .After|.Figure | |00001ab0| 31 0d 41 20 43 6f 75 70 | 6c 65 20 6f 66 20 43 72 |1.A Coup|le of Cr| |00001ac0| 61 7a 79 20 47 75 79 73 | 2c 20 42 65 66 6f 72 65 |azy Guys|, Before| |00001ad0| 20 61 6e 64 20 41 66 74 | 65 72 20 52 65 64 2f 47 | and Aft|er Red/G| |00001ae0| 72 65 65 6e 20 49 6e 76 | 65 72 73 69 6f 6e 0d 41 |reen Inv|ersion.A| |00001af0| 73 20 73 68 6f 77 6e 20 | 68 65 72 65 2c 20 77 65 |s shown |here, we| |00001b00| 20 75 73 65 20 74 68 65 | 20 51 75 69 63 6b 44 72 | use the| QuickDr| |00001b10| 61 77 20 72 6f 75 74 69 | 6e 65 73 20 47 65 74 43 |aw routi|nes GetC| |00001b20| 50 69 78 65 6c 20 61 6e | 64 20 53 65 74 43 50 69 |Pixel an|d SetCPi| |00001b30| 78 65 6c 20 74 6f 20 67 | 65 74 20 61 6e 64 20 73 |xel to g|et and s| |00001b40| 65 74 20 74 68 65 20 63 | 6f 6c 6f 72 20 6f 66 20 |et the c|olor of | |00001b50| 61 20 73 69 6e 67 6c 65 | 20 70 69 78 65 6c 2e 20 |a single| pixel. | |00001b60| 53 65 74 43 50 69 78 65 | 6c 20 69 73 20 63 6f 6e |SetCPixe|l is con| |00001b70| 76 65 72 74 65 64 20 74 | 6f 20 61 20 6c 69 6e 65 |verted t|o a line| |00001b80| 2d 64 72 61 77 69 6e 67 | 20 63 6f 6d 6d 61 6e 64 |-drawing| command| |00001b90| 2c 20 62 65 63 61 75 73 | 65 20 73 65 74 74 69 6e |, becaus|e settin| |00001ba0| 67 20 61 20 73 69 6e 67 | 6c 65 20 70 69 78 65 6c |g a sing|le pixel| |00001bb0| 20 69 73 20 61 63 74 75 | 61 6c 6c 79 20 61 20 73 | is actu|ally a s| |00001bc0| 70 65 63 69 61 6c 20 63 | 61 73 65 20 6f 66 20 64 |pecial c|ase of d| |00001bd0| 72 61 77 69 6e 67 20 61 | 20 6c 69 6e 65 20 28 61 |rawing a| line (a| |00001be0| 20 76 65 72 79 20 73 68 | 6f 72 74 20 6c 69 6e 65 | very sh|ort line| |00001bf0| 21 29 2e 20 54 68 69 73 | 20 77 61 79 20 6f 66 20 |!). This| way of | |00001c00| 69 6d 70 6c 65 6d 65 6e | 74 69 6e 67 20 70 69 78 |implemen|ting pix| |00001c10| 65 6c 20 73 65 74 74 69 | 6e 67 20 69 73 20 61 64 |el setti|ng is ad| |00001c20| 76 61 6e 74 61 67 65 6f | 75 73 20 62 65 63 61 75 |vantageo|us becau| |00001c30| 73 65 20 6c 69 6e 65 2d | 64 72 61 77 69 6e 67 20 |se line-|drawing | |00001c40| 6f 70 65 72 61 74 69 6f | 6e 73 20 61 72 65 20 73 |operatio|ns are s| |00001c50| 61 76 65 64 20 69 6e 20 | 70 69 63 74 75 72 65 73 |aved in |pictures| |00001c60| 20 61 6e 64 20 75 73 65 | 20 74 68 65 20 70 61 74 | and use| the pat| |00001c70| 74 65 72 6e 20 61 6e 64 | 20 74 72 61 6e 73 66 65 |tern and| transfe| |00001c80| 72 20 6d 6f 64 65 20 66 | 72 6f 6d 20 74 68 65 20 |r mode f|rom the | |00001c90| 70 6f 72 74 2e 20 49 74 | 20 61 6c 73 6f 20 73 69 |port. It| also si| |00001ca0| 6d 70 6c 69 66 69 65 73 | 20 51 75 69 63 6b 44 72 |mplifies| QuickDr| |00001cb0| 61 77 20 6f 6e 20 74 68 | 65 20 62 6f 74 74 6c 65 |aw on th|e bottle| |00001cc0| 6e 65 63 6b 20 6c 65 76 | 65 6c 20 73 69 6e 63 65 |neck lev|el since| |00001cd0| 20 6e 6f 20 73 65 70 61 | 72 61 74 65 20 62 6f 74 | no sepa|rate bot| |00001ce0| 74 6c 65 6e 65 63 6b 20 | 72 6f 75 74 69 6e 65 20 |tleneck |routine | |00001cf0| 65 78 69 73 74 73 20 66 | 6f 72 20 73 65 74 74 69 |exists f|or setti| |00001d00| 6e 67 20 70 69 78 65 6c | 73 2e 20 54 68 65 20 64 |ng pixel|s. The d| |00001d10| 6f 77 6e 73 69 64 65 20 | 69 73 20 74 68 61 74 20 |ownside |is that | |00001d20| 73 65 74 74 69 6e 67 20 | 61 20 73 69 6e 67 6c 65 |setting |a single| |00001d30| 20 70 69 78 65 6c 20 74 | 68 69 73 20 77 61 79 20 | pixel t|his way | |00001d40| 69 73 20 73 6c 6f 77 2e | 20 54 6f 20 70 72 6f 64 |is slow.| To prod| |00001d50| 75 63 65 20 74 68 65 20 | 74 72 61 6e 73 66 6f 72 |uce the |transfor| |00001d60| 6d 61 74 69 6f 6e 20 73 | 68 6f 77 6e 20 69 6e 20 |mation s|hown in | |00001d70| 46 69 67 75 72 65 20 31 | 2c 20 74 68 65 20 63 6f |Figure 1|, the co| |00001d80| 64 65 20 74 61 6b 65 73 | 20 36 32 34 20 74 69 63 |de takes| 624 tic| |00001d90| 6b 73 20 6f 72 20 61 62 | 6f 75 74 20 31 30 2e 34 |ks or ab|out 10.4| |00001da0| 20 73 65 63 6f 6e 64 73 | 20 74 6f 20 72 75 6e 20 | seconds| to run | |00001db0| 6f 6e 20 61 20 4d 61 63 | 69 6e 74 6f 73 68 20 49 |on a Mac|intosh I| |00001dc0| 49 66 78 2e 0d 46 61 73 | 74 65 72 2e 20 4e 6f 77 |Ifx..Fas|ter. Now| |00001dd0| 20 6c 65 74 d5 73 20 64 | 65 76 65 6c 6f 70 20 61 | let.s d|evelop a| |00001de0| 20 63 75 73 74 6f 6d 20 | 72 6f 75 74 69 6e 65 20 | custom |routine | |00001df0| 74 68 61 74 20 6f 70 74 | 69 6d 69 7a 65 73 20 73 |that opt|imizes s| |00001e00| 65 74 74 69 6e 67 20 61 | 20 73 69 6e 67 6c 65 20 |etting a| single | |00001e10| 70 69 78 65 6c 2e 20 46 | 6f 72 20 61 20 66 69 72 |pixel. F|or a fir| |00001e20| 73 74 20 70 61 73 73 2c | 20 77 65 d5 6c 6c 20 65 |st pass,| we.ll e| |00001e30| 6c 69 6d 69 6e 61 74 65 | 20 74 68 65 20 6d 61 6a |liminate| the maj| |00001e40| 6f 72 69 74 79 20 6f 66 | 20 74 68 65 20 6f 76 65 |ority of| the ove| |00001e50| 72 68 65 61 64 20 61 6e | 64 20 73 65 74 20 74 68 |rhead an|d set th| |00001e60| 65 20 70 69 78 65 6c 20 | 64 69 72 65 63 74 6c 79 |e pixel |directly| |00001e70| 20 72 61 74 68 65 72 20 | 74 68 61 6e 20 64 6f 20 | rather |than do | |00001e80| 6c 69 6e 65 20 64 72 61 | 77 69 6e 67 2e 20 47 69 |line dra|wing. Gi| |00001e90| 76 65 6e 20 61 20 47 57 | 6f 72 6c 64 50 74 72 2c |ven a GW|orldPtr,| |00001ea0| 20 61 6e 20 78 20 61 6e | 64 20 79 20 70 6f 73 69 | an x an|d y posi| |00001eb0| 74 69 6f 6e 2c 20 61 6e | 64 20 61 20 33 32 2d 62 |tion, an|d a 32-b| |00001ec0| 69 74 20 76 61 6c 75 65 | 2c 20 6f 75 72 20 72 6f |it value|, our ro| |00001ed0| 75 74 69 6e 65 20 47 57 | 53 65 74 33 32 50 69 78 |utine GW|Set32Pix| |00001ee0| 65 6c 43 20 73 65 74 73 | 20 74 68 65 20 70 69 78 |elC sets| the pix| |00001ef0| 65 6c 20 61 74 20 74 68 | 61 74 20 70 6f 73 69 74 |el at th|at posit| |00001f00| 69 6f 6e 20 74 6f 20 74 | 68 61 74 20 76 61 6c 75 |ion to t|hat valu| |00001f10| 65 2e 20 54 68 65 20 70 | 61 72 61 6c 6c 65 6c 20 |e. The p|arallel | |00001f20| 63 61 6c 6c 20 47 57 47 | 65 74 33 32 50 69 78 65 |call GWG|et32Pixe| |00001f30| 6c 43 20 69 73 20 69 64 | 65 6e 74 69 63 61 6c 2c |lC is id|entical,| |00001f40| 20 65 78 63 65 70 74 20 | 74 68 61 74 20 77 68 65 | except |that whe| |00001f50| 72 65 20 47 57 53 65 74 | 33 32 50 69 78 65 6c 43 |re GWSet|32PixelC| |00001f60| 20 73 65 74 73 20 74 68 | 65 20 76 61 6c 75 65 2c | sets th|e value,| |00001f70| 20 47 57 47 65 74 33 32 | 50 69 78 65 6c 43 20 72 | GWGet32|PixelC r| |00001f80| 65 74 75 72 6e 73 20 69 | 74 2e 0d 47 57 53 65 74 |eturns i|t..GWSet| |00001f90| 33 32 50 69 78 65 6c 43 | 28 47 57 6f 72 6c 64 50 |32PixelC|(GWorldP| |00001fa0| 74 72 20 73 72 63 2c 20 | 73 68 6f 72 74 20 78 2c |tr src, |short x,| |00001fb0| 20 73 68 6f 72 74 20 79 | 2c 20 6c 6f 6e 67 20 70 | short y|, long p| |00001fc0| 69 78 65 6c 56 61 6c 75 | 65 29 0d 7b 0d 50 69 78 |ixelValu|e).{.Pix| |00001fd0| 4d 61 70 48 61 6e 64 6c | 65 09 09 73 72 63 50 69 |MapHandl|e..srcPi| |00001fe0| 78 4d 61 70 3b 0d 75 6e | 73 69 67 6e 65 64 20 73 |xMap;.un|signed s| |00001ff0| 68 6f 72 74 09 73 72 63 | 52 6f 77 42 79 74 65 73 |hort.src|RowBytes| |00002000| 3b 0d 6c 6f 6e 67 09 09 | 09 09 09 73 72 63 42 61 |;.long..|...srcBa| |00002010| 73 65 41 64 64 72 3b 0d | 6c 6f 6e 67 09 09 09 09 |seAddr;.|long....| |00002020| 09 73 72 63 41 64 64 72 | 3b 0d 63 68 61 72 09 09 |.srcAddr|;.char..| |00002030| 09 09 09 6d 6d 75 4d 6f | 64 65 3b 0d 09 73 72 63 |...mmuMo|de;..src| |00002040| 50 69 78 4d 61 70 20 3d | 20 47 65 74 47 57 6f 72 |PixMap =| GetGWor| |00002050| 6c 64 50 69 78 4d 61 70 | 28 73 72 63 29 3b 0d 09 |ldPixMap|(src);..| |00002060| 2f 2a 20 47 65 74 20 74 | 68 65 20 61 64 64 72 65 |/* Get t|he addre| |00002070| 73 73 20 6f 66 20 74 68 | 65 20 70 69 78 65 6c 73 |ss of th|e pixels| |00002080| 2e 20 2a 2f 0d 09 73 72 | 63 42 61 73 65 41 64 64 |. */..sr|cBaseAdd| |00002090| 72 20 3d 20 28 6c 6f 6e | 67 29 20 47 65 74 50 69 |r = (lon|g) GetPi| |000020a0| 78 42 61 73 65 41 64 64 | 72 28 73 72 63 50 69 78 |xBaseAdd|r(srcPix| |000020b0| 4d 61 70 29 3b 0d 09 2f | 2a 20 47 65 74 20 74 68 |Map);../|* Get th| |000020c0| 65 20 72 6f 77 20 69 6e | 63 72 65 6d 65 6e 74 2e |e row in|crement.| |000020d0| 20 2a 2f 0d 09 73 72 63 | 52 6f 77 42 79 74 65 73 | */..src|RowBytes| |000020e0| 20 3d 20 28 2a 2a 73 72 | 63 50 69 78 4d 61 70 29 | = (**sr|cPixMap)| |000020f0| 2e 72 6f 77 42 79 74 65 | 73 20 26 20 30 78 37 66 |.rowByte|s & 0x7f| |00002100| 66 66 3b 0d 09 2f 2a 20 | 4d 61 6b 65 20 63 6f 6f |ff;../* |Make coo| |00002110| 72 64 69 6e 61 74 65 73 | 20 70 69 78 65 6c 20 6d |rdinates| pixel m| |00002120| 61 70 20 72 65 6c 61 74 | 69 76 65 2e 20 2a 2f 0d |ap relat|ive. */.| |00002130| 09 78 20 2d 3d 20 28 2a | 2a 73 72 63 50 69 78 4d |.x -= (*|*srcPixM| |00002140| 61 70 29 2e 62 6f 75 6e | 64 73 2e 6c 65 66 74 3b |ap).boun|ds.left;| |00002150| 0d 09 79 20 2d 3d 20 28 | 2a 2a 73 72 63 50 69 78 |..y -= (|**srcPix| |00002160| 4d 61 70 29 2e 62 6f 75 | 6e 64 73 2e 74 6f 70 3b |Map).bou|nds.top;| |00002170| 0d 09 6d 6d 75 4d 6f 64 | 65 20 3d 20 74 72 75 65 |..mmuMod|e = true| |00002180| 33 32 62 3b 0d 09 53 77 | 61 70 4d 4d 55 4d 6f 64 |32b;..Sw|apMMUMod| |00002190| 65 28 26 6d 6d 75 4d 6f | 64 65 29 3b 09 09 09 2f |e(&mmuMo|de);.../| |000021a0| 2a 20 53 65 74 20 74 68 | 65 20 4d 4d 55 20 74 6f |* Set th|e MMU to| |000021b0| 20 33 32 2d 62 69 74 20 | 6d 6f 64 65 2e 20 2a 2f | 32-bit |mode. */| |000021c0| 0d 09 2f 2a 20 43 61 6c | 63 75 6c 61 74 65 20 74 |../* Cal|culate t| |000021d0| 68 65 20 61 64 64 72 65 | 73 73 20 6f 66 20 74 68 |he addre|ss of th| |000021e0| 65 20 70 69 78 65 6c 3a | 20 20 62 61 73 65 20 2b |e pixel:| base +| |000021f0| 20 79 2a 28 72 6f 77 20 | 73 69 7a 65 20 69 6e 0d | y*(row |size in.| |00002200| 09 09 62 79 74 65 73 29 | 20 2b 20 78 2a 28 62 79 |..bytes)| + x*(by| |00002210| 74 65 73 2f 70 69 78 65 | 6c 29 2e 20 2a 2f 0d 09 |tes/pixe|l). */..| |00002220| 73 72 63 41 64 64 72 20 | 3d 20 73 72 63 42 61 73 |srcAddr |= srcBas| |00002230| 65 41 64 64 72 20 2b 20 | 28 6c 6f 6e 67 29 79 2a |eAddr + |(long)y*| |00002240| 73 72 63 52 6f 77 42 79 | 74 65 73 20 2b 20 28 78 |srcRowBy|tes + (x| |00002250| 20 3c 3c 20 32 29 3b 0d | 09 2a 28 28 6c 6f 6e 67 | << 2);.|.*((long| |00002260| 20 2a 29 73 72 63 41 64 | 64 72 29 20 3d 20 70 69 | *)srcAd|dr) = pi| |00002270| 78 65 6c 56 61 6c 75 65 | 3b 0d 09 53 77 61 70 4d |xelValue|;..SwapM| |00002280| 4d 55 4d 6f 64 65 28 26 | 6d 6d 75 4d 6f 64 65 29 |MUMode(&|mmuMode)| |00002290| 3b 09 09 2f 2a 20 52 65 | 73 74 6f 72 65 20 74 68 |;../* Re|store th| |000022a0| 65 20 70 72 65 76 69 6f | 75 73 20 4d 4d 55 20 6d |e previo|us MMU m| |000022b0| 6f 64 65 2e 20 2a 2f 0d | 7d 0d 4f 66 20 69 6e 74 |ode. */.|}.Of int| |000022c0| 65 72 65 73 74 20 69 6e | 20 74 68 69 73 20 63 6f |erest in| this co| |000022d0| 64 65 20 69 73 20 74 68 | 65 20 63 61 6c 6c 20 74 |de is th|e call t| |000022e0| 6f 20 53 77 61 70 4d 4d | 55 4d 6f 64 65 20 62 65 |o SwapMM|UMode be| |000022f0| 66 6f 72 65 20 64 72 61 | 77 69 6e 67 20 74 6f 20 |fore dra|wing to | |00002300| 74 68 65 20 47 57 6f 72 | 6c 64 2e 20 54 68 69 73 |the GWor|ld. This| |00002310| 20 69 73 20 6e 65 63 65 | 73 73 61 72 79 20 73 69 | is nece|ssary si| |00002320| 6e 63 65 20 74 68 65 20 | 47 57 6f 72 6c 64 20 63 |nce the |GWorld c| |00002330| 6f 75 6c 64 20 62 65 20 | 63 61 63 68 65 64 20 6f |ould be |cached o| |00002340| 6e 20 61 6e 20 61 63 63 | 65 6c 65 72 61 74 6f 72 |n an acc|elerator| |00002350| 20 63 61 72 64 20 61 6e | 64 20 72 65 71 75 69 72 | card an|d requir| |00002360| 65 20 33 32 2d 62 69 74 | 20 61 64 64 72 65 73 73 |e 32-bit| address| |00002370| 69 6e 67 20 74 6f 20 61 | 63 63 65 73 73 20 69 74 |ing to a|ccess it| |00002380| 2e 20 28 53 65 65 20 d2 | 51 75 69 63 6b 44 72 61 |. (See .|QuickDra| |00002390| 77 d5 73 20 43 6f 70 79 | 42 69 74 73 20 50 72 6f |w.s Copy|Bits Pro| |000023a0| 63 65 64 75 72 65 d3 20 | 69 6e 20 64 65 76 65 6c |cedure. |in devel| |000023b0| 6f 70 20 49 73 73 75 65 | 20 36 20 66 6f 72 20 61 |op Issue| 6 for a| |000023c0| 20 63 6f 6d 70 6c 65 74 | 65 20 65 78 70 6c 61 6e | complet|e explan| |000023d0| 61 74 69 6f 6e 2e 29 0d | 49 66 20 77 65 20 72 65 |ation.).|If we re| |000023e0| 76 69 73 65 20 6f 75 72 | 20 73 61 6d 70 6c 65 20 |vise our| sample | |000023f0| 63 6f 64 65 20 74 6f 20 | 75 73 65 20 6f 75 72 20 |code to |use our | |00002400| 6e 65 77 20 63 61 6c 6c | 73 20 47 57 47 65 74 33 |new call|s GWGet3| |00002410| 32 50 69 78 65 6c 43 20 | 61 6e 64 20 47 57 53 65 |2PixelC |and GWSe| |00002420| 74 33 32 50 69 78 65 6c | 43 2c 20 74 68 65 20 69 |t32Pixel|C, the i| |00002430| 6d 61 67 65 20 73 68 6f | 77 6e 20 69 6e 20 46 69 |mage sho|wn in Fi| |00002440| 67 75 72 65 20 31 20 74 | 61 6b 65 73 20 33 39 38 |gure 1 t|akes 398| |00002450| 20 74 69 63 6b 73 20 28 | 6f 72 20 36 2e 38 20 73 | ticks (|or 6.8 s| |00002460| 65 63 6f 6e 64 73 29 20 | 74 6f 20 70 72 6f 63 65 |econds) |to proce| |00002470| 73 73 2e 20 54 68 69 73 | 20 69 73 20 61 62 6f 75 |ss. This| is abou| |00002480| 74 20 36 35 25 20 66 61 | 73 74 65 72 20 74 68 61 |t 65% fa|ster tha| |00002490| 6e 20 51 75 69 63 6b 44 | 72 61 77 2c 20 62 75 74 |n QuickD|raw, but| |000024a0| 20 69 73 20 73 74 69 6c | 6c 20 6d 75 63 68 20 73 | is stil|l much s| |000024b0| 6c 6f 77 65 72 20 74 68 | 61 6e 20 69 74 20 6e 65 |lower th|an it ne| |000024c0| 65 64 73 20 74 6f 20 62 | 65 2e 0d 41 6e 64 20 66 |eds to b|e..And f| |000024d0| 61 73 74 65 72 2e 20 54 | 68 65 72 65 20 61 72 65 |aster. T|here are| |000024e0| 20 74 77 6f 20 6d 61 6a | 6f 72 20 69 6e 65 66 66 | two maj|or ineff| |000024f0| 69 63 69 65 6e 63 69 65 | 73 20 69 6e 20 6f 75 72 |iciencie|s in our| |00002500| 20 73 61 6d 70 6c 65 20 | 63 6f 64 65 3a 20 69 74 | sample |code: it| |00002510| 20 6d 61 6b 65 73 20 66 | 6f 75 72 20 74 72 61 70 | makes f|our trap| |00002520| 20 63 61 6c 6c 73 20 61 | 6e 64 20 69 74 d5 73 20 | calls a|nd it.s | |00002530| 61 74 20 74 68 65 20 6d | 65 72 63 79 20 6f 66 20 |at the m|ercy of | |00002540| 74 68 65 20 43 20 63 6f | 6d 70 69 6c 65 72 2e 20 |the C co|mpiler. | |00002550| 42 6f 74 68 20 6f 66 20 | 74 68 65 73 65 20 70 72 |Both of |these pr| |00002560| 6f 62 6c 65 6d 73 20 61 | 72 65 20 65 61 73 69 6c |oblems a|re easil| |00002570| 79 20 6f 76 65 72 63 6f | 6d 65 2c 20 61 73 20 74 |y overco|me, as t| |00002580| 68 65 20 46 61 73 74 47 | 57 53 65 74 33 32 50 69 |he FastG|WSet32Pi| |00002590| 78 65 6c 20 72 6f 75 74 | 69 6e 65 20 64 65 6d 6f |xel rout|ine demo| |000025a0| 6e 73 74 72 61 74 65 73 | 2e 20 52 61 74 68 65 72 |nstrates|. Rather| |000025b0| 20 74 68 61 6e 20 74 61 | 6b 65 20 61 20 47 57 6f | than ta|ke a GWo| |000025c0| 72 6c 64 50 74 72 2c 20 | 46 61 73 74 47 57 53 65 |rldPtr, |FastGWSe| |000025d0| 74 33 32 50 69 78 65 6c | 20 74 61 6b 65 73 20 61 |t32Pixel| takes a| |000025e0| 20 70 69 78 4d 61 70 20 | 70 6f 69 6e 74 65 72 20 | pixMap |pointer | |000025f0| 61 6e 64 20 61 20 62 61 | 73 65 20 61 64 64 72 65 |and a ba|se addre| |00002600| 73 73 2e 20 46 75 72 74 | 68 65 72 6d 6f 72 65 2c |ss. Furt|hermore,| |00002610| 20 74 68 65 20 72 6f 75 | 74 69 6e 65 20 61 73 73 | the rou|tine ass| |00002620| 75 6d 65 73 20 69 74 d5 | 73 20 62 65 69 6e 67 20 |umes it.|s being | |00002630| 63 61 6c 6c 65 64 20 69 | 6e 20 33 32 2d 62 69 74 |called i|n 32-bit| |00002640| 20 6d 6f 64 65 2e 20 4e | 6f 74 65 20 74 68 61 74 | mode. N|ote that| |00002650| 20 74 68 65 20 76 61 72 | 69 61 62 6c 65 73 20 62 | the var|iables b| |00002660| 6f 75 6e 64 73 2c 20 74 | 6f 70 2c 20 72 6f 77 42 |ounds, t|op, rowB| |00002670| 79 74 65 73 2c 20 61 6e | 64 20 6c 65 66 74 20 61 |ytes, an|d left a| |00002680| 72 65 20 64 65 66 69 6e | 65 64 20 69 6e 20 51 75 |re defin|ed in Qu| |00002690| 69 63 6b 45 71 75 61 74 | 65 2e 61 2e 0d 46 61 73 |ickEquat|e.a..Fas| |000026a0| 74 47 57 53 65 74 33 32 | 50 69 78 65 6c 28 50 69 |tGWSet32|Pixel(Pi| |000026b0| 78 4d 61 70 20 2a 73 72 | 63 50 69 78 4d 61 70 2c |xMap *sr|cPixMap,| |000026c0| 20 6c 6f 6e 67 20 2a 73 | 72 63 42 61 73 65 41 64 | long *s|rcBaseAd| |000026d0| 64 72 2c 20 73 68 6f 72 | 74 20 78 2c 20 0d 09 73 |dr, shor|t x, ..s| |000026e0| 68 6f 72 74 20 79 2c 20 | 6c 6f 6e 67 20 70 69 78 |hort y, |long pix| |000026f0| 65 6c 56 61 6c 75 65 29 | 0d 7b 0d 09 61 73 6d 20 |elValue)|.{..asm | |00002700| 7b 0d 09 09 6d 6f 76 65 | 2e 6c 09 09 73 72 63 50 |{...move|.l..srcP| |00002710| 69 78 4d 61 70 2c 61 30 | 09 09 09 3b 4d 75 73 74 |ixMap,a0|...;Must| |00002720| 20 62 65 20 33 32 2d 62 | 69 74 2d 63 6c 65 61 6e | be 32-b|it-clean| |00002730| 20 70 6f 69 6e 74 65 72 | 0d 09 09 6d 6f 76 65 2e | pointer|...move.| |00002740| 77 09 09 79 2c 64 31 09 | 09 09 09 09 09 3b 47 65 |w..y,d1.|.....;Ge| |00002750| 74 20 79 0d 09 09 73 75 | 62 2e 77 09 09 62 6f 75 |t y...su|b.w..bou| |00002760| 6e 64 73 2b 74 6f 70 28 | 61 30 29 2c 64 31 09 3b |nds+top(|a0),d1.;| |00002770| 4d 61 6b 65 20 79 20 62 | 6f 75 6e 64 73 20 30 20 |Make y b|ounds 0 | |00002780| 72 65 6c 61 74 69 76 65 | 0d 09 09 6d 6f 76 65 2e |relative|...move.| |00002790| 77 09 09 72 6f 77 42 79 | 74 65 73 28 61 30 29 2c |w..rowBy|tes(a0),| |000027a0| 64 30 09 09 3b 47 65 74 | 20 72 6f 77 42 79 74 65 |d0..;Get| rowByte| |000027b0| 73 0d 09 09 61 6e 64 2e | 77 09 09 23 30 78 37 46 |s...and.|w..#0x7F| |000027c0| 46 46 2c 64 30 09 09 09 | 09 3b 53 74 72 69 70 20 |FF,d0...|.;Strip | |000027d0| 62 69 74 6d 61 70 2f 70 | 69 78 4d 61 70 20 62 69 |bitmap/p|ixMap bi| |000027e0| 74 0d 09 09 6d 75 6c 75 | 2e 77 09 09 64 30 2c 64 |t...mulu|.w..d0,d| |000027f0| 31 09 09 09 09 09 3b 43 | 61 6c 63 75 6c 61 74 65 |1.....;C|alculate| |00002800| 20 6f 66 66 73 65 74 20 | 74 6f 20 73 74 61 72 74 | offset |to start| |00002810| 20 6f 66 20 74 68 69 73 | 20 72 6f 77 0d 09 09 6d | of this| row...m| |00002820| 6f 76 65 2e 6c 09 09 73 | 72 63 42 61 73 65 41 64 |ove.l..s|rcBaseAd| |00002830| 64 72 2c 61 31 09 09 3b | 4d 75 73 74 20 62 65 20 |dr,a1..;|Must be | |00002840| 33 32 2d 62 69 74 20 62 | 61 73 65 20 61 64 64 72 |32-bit b|ase addr| |00002850| 65 73 73 0d 09 09 61 64 | 64 61 2e 6c 09 09 64 31 |ess...ad|da.l..d1| |00002860| 2c 61 31 09 09 09 09 09 | 3b 43 61 6c 63 75 6c 61 |,a1.....|;Calcula| |00002870| 74 65 20 61 64 64 72 65 | 73 73 20 6f 66 20 74 68 |te addre|ss of th| |00002880| 69 73 20 72 6f 77 0d 09 | 09 6d 6f 76 65 71 09 09 |is row..|.moveq..| |00002890| 23 30 2c 64 30 09 09 09 | 09 09 3b 45 78 74 65 6e |#0,d0...|..;Exten| |000028a0| 64 20 78 20 74 6f 20 61 | 20 77 6f 72 64 0d 09 09 |d x to a| word...| |000028b0| 6d 6f 76 65 2e 77 09 09 | 78 2c 64 30 0d 09 09 73 |move.w..|x,d0...s| |000028c0| 75 62 2e 77 09 09 62 6f | 75 6e 64 73 2b 6c 65 66 |ub.w..bo|unds+lef| |000028d0| 74 28 61 30 29 2c 64 30 | 09 3b 4d 61 6b 65 20 78 |t(a0),d0|.;Make x| |000028e0| 20 62 6f 75 6e 64 73 20 | 30 20 72 65 6c 61 74 69 | bounds |0 relati| |000028f0| 76 65 0d 09 09 6c 73 6c | 2e 77 09 09 23 32 2c 64 |ve...lsl|.w..#2,d| |00002900| 30 09 09 09 09 09 3b 43 | 6f 6e 76 65 72 74 20 78 |0.....;C|onvert x| |00002910| 20 74 6f 20 70 69 78 65 | 6c 73 20 28 34 20 62 79 | to pixe|ls (4 by| |00002920| 74 65 73 2f 70 69 78 65 | 6c 29 0d 09 09 61 64 64 |tes/pixe|l)...add| |00002930| 61 2e 6c 09 09 64 30 2c | 61 31 09 09 09 09 09 3b |a.l..d0,|a1.....;| |00002940| 43 61 6c 63 75 6c 61 74 | 65 20 70 69 78 65 6c 20 |Calculat|e pixel | |00002950| 61 64 64 72 65 73 73 0d | 09 09 6d 6f 76 65 2e 6c |address.|..move.l| |00002960| 09 09 70 69 78 65 6c 56 | 61 6c 75 65 2c 28 61 31 |..pixelV|alue,(a1| |00002970| 29 0d 09 7d 0d 7d 0d 59 | 6f 75 20 6d 61 79 20 77 |)..}.}.Y|ou may w| |00002980| 6f 6e 64 65 72 20 77 68 | 79 20 74 68 69 73 20 72 |onder wh|y this r| |00002990| 6f 75 74 69 6e 65 20 74 | 61 6b 65 73 20 62 6f 74 |outine t|akes bot| |000029a0| 68 20 61 20 70 69 78 4d | 61 70 20 61 6e 64 20 61 |h a pixM|ap and a| |000029b0| 20 62 61 73 65 20 61 64 | 64 72 65 73 73 2e 20 43 | base ad|dress. C| |000029c0| 61 6e d5 74 20 69 74 20 | 6a 75 73 74 20 67 65 74 |an.t it |just get| |000029d0| 20 74 68 65 20 62 61 73 | 65 20 61 64 64 72 65 73 | the bas|e addres| |000029e0| 73 20 66 72 6f 6d 20 74 | 68 65 20 70 69 78 4d 61 |s from t|he pixMa| |000029f0| 70 20 64 69 72 65 63 74 | 6c 79 3f 20 54 68 65 20 |p direct|ly? The | |00002a00| 61 6e 73 77 65 72 20 69 | 73 20 6e 6f 2c 20 73 69 |answer i|s no, si| |00002a10| 6e 63 65 20 74 68 65 20 | 62 61 73 65 20 61 64 64 |nce the |base add| |00002a20| 72 65 73 73 20 6f 66 20 | 61 20 47 57 6f 72 6c 64 |ress of |a GWorld| |00002a30| 20 63 61 6e 20 62 65 20 | 61 20 68 61 6e 64 6c 65 | can be |a handle| |00002a40| 20 72 61 74 68 65 72 20 | 74 68 61 6e 20 61 20 70 | rather |than a p| |00002a50| 6f 69 6e 74 65 72 20 61 | 6e 64 20 69 6e 20 74 68 |ointer a|nd in th| |00002a60| 65 20 66 75 74 75 72 65 | 20 6d 69 67 68 74 20 62 |e future| might b| |00002a70| 65 20 73 6f 6d 65 74 68 | 69 6e 67 20 64 69 66 66 |e someth|ing diff| |00002a80| 65 72 65 6e 74 20 61 67 | 61 69 6e 2e 20 59 6f 75 |erent ag|ain. You| |00002a90| 20 6d 75 73 74 20 70 61 | 73 73 20 69 6e 20 61 20 | must pa|ss in a | |00002aa0| 62 61 73 65 20 61 64 64 | 72 65 73 73 20 74 68 61 |base add|ress tha| |00002ab0| 74 d5 73 20 67 6f 6f 64 | 20 69 6e 20 33 32 2d 62 |t.s good| in 32-b| |00002ac0| 69 74 20 61 64 64 72 65 | 73 73 69 6e 67 20 6d 6f |it addre|ssing mo| |00002ad0| 64 65 2e 20 54 68 65 20 | 47 65 74 50 69 78 42 61 |de. The |GetPixBa| |00002ae0| 73 65 41 64 64 72 20 72 | 6f 75 74 69 6e 65 20 63 |seAddr r|outine c| |00002af0| 61 6c 6c 65 64 20 62 79 | 20 47 57 53 65 74 33 32 |alled by| GWSet32| |00002b00| 50 69 78 65 6c 43 20 72 | 65 74 75 72 6e 73 20 74 |PixelC r|eturns t| |00002b10| 68 65 20 63 6f 72 72 65 | 63 74 20 62 61 73 65 20 |he corre|ct base | |00002b20| 61 64 64 72 65 73 73 20 | 67 69 76 65 6e 20 61 20 |address |given a | |00002b30| 70 69 78 4d 61 70 2e 0d | 52 65 76 69 73 69 6e 67 |pixMap..|Revising| |00002b40| 20 6f 75 72 20 73 61 6d | 70 6c 65 20 63 6f 64 65 | our sam|ple code| |00002b50| 20 69 73 6e d5 74 20 61 | 73 20 74 72 69 76 69 61 | isn.t a|s trivia| |00002b60| 6c 20 61 73 20 69 74 20 | 77 61 73 20 62 65 66 6f |l as it |was befo| |00002b70| 72 65 20 62 65 63 61 75 | 73 65 20 6f 66 20 74 68 |re becau|se of th| |00002b80| 65 20 61 64 64 69 74 69 | 6f 6e 61 6c 20 61 73 73 |e additi|onal ass| |00002b90| 75 6d 70 74 69 6f 6e 73 | 20 6d 61 64 65 20 62 79 |umptions| made by| |00002ba0| 20 74 68 65 73 65 20 66 | 61 73 74 20 67 65 74 20 | these f|ast get | |00002bb0| 61 6e 64 20 73 65 74 20 | 70 69 78 65 6c 20 72 6f |and set |pixel ro| |00002bc0| 75 74 69 6e 65 73 2e 20 | 48 65 72 65 d5 73 20 74 |utines. |Here.s t| |00002bd0| 68 65 20 6e 65 77 20 76 | 65 72 73 69 6f 6e 20 6f |he new v|ersion o| |00002be0| 66 20 74 68 65 20 63 6f | 64 65 3a 0d 2f 2a 20 47 |f the co|de:./* G| |00002bf0| 65 74 20 70 69 78 4d 61 | 70 27 73 20 33 32 2d 62 |et pixMa|p's 32-b| |00002c00| 69 74 20 62 61 73 65 20 | 61 64 64 72 65 73 73 2e |it base |address.| |00002c10| 20 2a 2f 0d 73 72 63 42 | 61 73 65 41 64 64 72 20 | */.srcB|aseAddr | |00002c20| 3d 20 28 6c 6f 6e 67 20 | 2a 29 20 47 65 74 50 69 |= (long |*) GetPi| |00002c30| 78 42 61 73 65 41 64 64 | 72 28 6d 79 50 69 78 4d |xBaseAdd|r(myPixM| |00002c40| 61 70 48 61 6e 64 6c 65 | 29 3b 0d 6d 79 50 69 78 |apHandle|);.myPix| |00002c50| 4d 61 70 50 74 72 20 3d | 20 2a 6d 79 50 69 78 4d |MapPtr =| *myPixM| |00002c60| 61 70 48 61 6e 64 6c 65 | 3b 0d 2f 2a 20 57 41 52 |apHandle|;./* WAR| |00002c70| 4e 49 4e 47 3a 20 54 68 | 65 20 70 69 78 4d 61 70 |NING: Th|e pixMap| |00002c80| 48 61 6e 64 6c 65 20 69 | 73 20 64 65 72 65 66 65 |Handle i|s derefe| |00002c90| 72 65 6e 63 65 64 20 74 | 68 72 6f 75 67 68 6f 75 |renced t|hroughou| |00002ca0| 74 20 74 68 65 73 65 20 | 6e 65 78 74 20 0d 09 6c |t these |next ..l| |00002cb0| 6f 6f 70 73 2e 20 54 68 | 65 20 63 6f 64 65 20 6d |oops. Th|e code m| |00002cc0| 61 6b 65 73 20 73 75 72 | 65 20 6d 65 6d 6f 72 79 |akes sur|e memory| |00002cd0| 20 77 69 6c 6c 20 6e 6f | 74 20 6d 6f 76 65 2e 20 | will no|t move. | |00002ce0| 49 6e 20 70 61 72 74 69 | 63 75 6c 61 72 2c 20 0d |In parti|cular, .| |00002cf0| 09 69 74 27 73 20 69 6d | 70 6f 72 74 61 6e 74 20 |.it's im|portant | |00002d00| 74 68 61 74 20 74 68 65 | 20 73 65 67 6d 65 6e 74 |that the| segment| |00002d10| 20 63 6f 6e 74 61 69 6e | 69 6e 67 20 74 68 65 20 | contain|ing the | |00002d20| 46 61 73 74 47 57 47 65 | 74 33 32 50 69 78 65 6c |FastGWGe|t32Pixel| |00002d30| 20 61 6e 64 20 0d 09 46 | 61 73 74 47 57 53 65 74 | and ..F|astGWSet| |00002d40| 33 32 50 69 78 65 6c 20 | 72 6f 75 74 69 6e 65 73 |32Pixel |routines| |00002d50| 20 69 73 20 61 6c 72 65 | 61 64 79 20 6c 6f 61 64 | is alre|ady load| |00002d60| 65 64 20 6f 72 20 69 73 | 20 69 6e 20 74 68 65 20 |ed or is| in the | |00002d70| 73 61 6d 65 20 0d 09 73 | 65 67 6d 65 6e 74 20 61 |same ..s|egment a| |00002d80| 73 20 74 68 65 20 63 61 | 6c 6c 65 72 2e 20 4f 74 |s the ca|ller. Ot| |00002d90| 68 65 72 77 69 73 65 20 | 6d 65 6d 6f 72 79 20 6d |herwise |memory m| |00002da0| 69 67 68 74 20 6d 6f 76 | 65 20 77 68 65 6e 20 74 |ight mov|e when t| |00002db0| 68 65 20 73 65 67 6d 65 | 6e 74 20 0d 09 69 73 20 |he segme|nt ..is | |00002dc0| 6c 6f 61 64 65 64 2e 20 | 41 20 74 72 69 63 6b 20 |loaded. |A trick | |00002dd0| 74 6f 20 6d 61 6b 65 20 | 73 75 72 65 20 74 68 65 |to make |sure the| |00002de0| 20 73 65 67 6d 65 6e 74 | 20 69 73 20 6c 6f 61 64 | segment| is load| |00002df0| 65 64 20 69 73 20 74 6f | 20 63 61 6c 6c 20 0d 09 |ed is to| call ..| |00002e00| 61 20 72 6f 75 74 69 6e | 65 20 69 6e 20 74 68 65 |a routin|e in the| |00002e10| 20 73 61 6d 65 20 73 65 | 67 6d 65 6e 74 20 28 6f | same se|gment (o| |00002e20| 72 20 74 68 65 73 65 20 | 72 6f 75 74 69 6e 65 73 |r these |routines| |00002e30| 20 74 68 65 6d 73 65 6c | 76 65 73 29 20 62 65 66 | themsel|ves) bef| |00002e40| 6f 72 65 20 0d 09 6d 61 | 6b 69 6e 67 20 61 73 73 |ore ..ma|king ass| |00002e50| 75 6d 70 74 69 6f 6e 73 | 20 61 62 6f 75 74 20 6d |umptions| about m| |00002e60| 65 6d 6f 72 79 20 6e 6f | 74 20 6d 6f 76 69 6e 67 |emory no|t moving| |00002e70| 2e 20 2a 2f 0d 2f 2a 20 | 4d 61 6b 65 20 69 74 20 |. */./* |Make it | |00002e80| 33 32 2d 62 69 74 20 63 | 6c 65 61 6e 2e 20 2a 2f |32-bit c|lean. */| |00002e90| 0d 4c 6f 63 6b 50 69 78 | 65 6c 73 28 6d 79 50 69 |.LockPix|els(myPi| |00002ea0| 78 4d 61 70 48 61 6e 64 | 6c 65 29 3b 0d 6d 79 50 |xMapHand|le);.myP| |00002eb0| 69 78 4d 61 70 50 74 72 | 20 3d 20 28 50 69 78 4d |ixMapPtr| = (PixM| |00002ec0| 61 70 20 2a 29 20 53 74 | 72 69 70 41 64 64 72 65 |ap *) St|ripAddre| |00002ed0| 73 73 28 28 50 74 72 29 | 6d 79 50 69 78 4d 61 70 |ss((Ptr)|myPixMap| |00002ee0| 50 74 72 29 3b 0d 0d 6d | 6d 75 4d 6f 64 65 20 3d |Ptr);..m|muMode =| |00002ef0| 20 74 72 75 65 33 32 62 | 3b 0d 53 77 61 70 4d 4d | true32b|;.SwapMM| |00002f00| 55 4d 6f 64 65 28 26 6d | 6d 75 4d 6f 64 65 29 3b |UMode(&m|muMode);| |00002f10| 09 09 09 2f 2a 20 53 65 | 74 20 74 68 65 20 4d 4d |.../* Se|t the MM| |00002f20| 55 20 74 6f 20 33 32 2d | 62 69 74 20 6d 6f 64 65 |U to 32-|bit mode| |00002f30| 2e 20 2a 2f 0d 66 6f 72 | 20 28 79 20 3d 20 62 6f |. */.for| (y = bo| |00002f40| 75 6e 64 73 2e 74 6f 70 | 3b 20 79 20 3c 20 62 6f |unds.top|; y < bo| |00002f50| 75 6e 64 73 2e 62 6f 74 | 74 6f 6d 3b 20 79 2b 2b |unds.bot|tom; y++| |00002f60| 29 0d 7b 0d 09 66 6f 72 | 20 28 78 20 3d 20 62 6f |).{..for| (x = bo| |00002f70| 75 6e 64 73 2e 6c 65 66 | 74 3b 20 78 20 3c 20 62 |unds.lef|t; x < b| |00002f80| 6f 75 6e 64 73 2e 72 69 | 67 68 74 3b 20 78 2b 2b |ounds.ri|ght; x++| |00002f90| 29 0d 09 7b 09 0d 09 09 | 6d 79 50 69 78 65 6c 20 |)..{....|myPixel | |00002fa0| 3d 20 46 61 73 74 47 57 | 47 65 74 33 32 50 69 78 |= FastGW|Get32Pix| |00002fb0| 65 6c 28 6d 79 50 69 78 | 4d 61 70 50 74 72 2c 20 |el(myPix|MapPtr, | |00002fc0| 73 72 63 42 61 73 65 41 | 64 64 72 2c 20 78 2c 20 |srcBaseA|ddr, x, | |00002fd0| 79 29 3b 0d 09 09 6d 79 | 50 69 78 65 6c 20 5e 3d |y);...my|Pixel ^=| |00002fe0| 20 30 78 30 30 46 46 46 | 46 30 30 3b 09 09 2f 2a | 0x00FFF|F00;../*| |00002ff0| 20 49 6e 76 65 72 74 20 | 74 68 65 20 72 65 64 20 | Invert |the red | |00003000| 61 6e 64 20 67 72 65 65 | 6e 20 63 68 61 6e 6e 65 |and gree|n channe| |00003010| 6c 73 2e 20 2a 2f 0d 09 | 09 46 61 73 74 47 57 53 |ls. */..|.FastGWS| |00003020| 65 74 33 32 50 69 78 65 | 6c 28 6d 79 50 69 78 4d |et32Pixe|l(myPixM| |00003030| 61 70 50 74 72 2c 20 73 | 72 63 42 61 73 65 41 64 |apPtr, s|rcBaseAd| |00003040| 64 72 2c 20 78 2c 20 79 | 2c 20 6d 79 50 69 78 65 |dr, x, y|, myPixe| |00003050| 6c 29 3b 0d 09 7d 0d 7d | 0d 53 77 61 70 4d 4d 55 |l);..}.}|.SwapMMU| |00003060| 4d 6f 64 65 28 26 6d 6d | 75 4d 6f 64 65 29 3b 09 |Mode(&mm|uMode);.| |00003070| 09 2f 2a 20 53 65 74 20 | 69 74 20 62 61 63 6b 2e |./* Set |it back.| |00003080| 20 2a 2f 0d 55 6e 6c 6f | 63 6b 50 69 78 65 6c 73 | */.Unlo|ckPixels| |00003090| 28 6d 79 50 69 78 4d 61 | 70 48 61 6e 64 6c 65 29 |(myPixMa|pHandle)| |000030a0| 3b 0d 4e 6f 74 65 20 74 | 68 61 74 20 74 68 65 20 |;.Note t|hat the | |000030b0| 63 6f 64 65 20 63 61 6c | 6c 73 20 53 74 72 69 70 |code cal|ls Strip| |000030c0| 41 64 64 72 65 73 73 20 | 6f 6e 20 74 68 65 20 70 |Address |on the p| |000030d0| 69 78 4d 61 70 50 74 72 | 20 73 69 6e 63 65 20 69 |ixMapPtr| since i| |000030e0| 74 d5 6c 6c 20 62 65 20 | 75 73 65 64 20 69 6e 20 |t.ll be |used in | |000030f0| 33 32 2d 62 69 74 20 6d | 6f 64 65 2e 20 41 6c 73 |32-bit m|ode. Als| |00003100| 6f 20 6e 6f 74 65 20 74 | 68 61 74 20 61 6c 74 68 |o note t|hat alth| |00003110| 6f 75 67 68 20 77 65 20 | 6c 6f 63 6b 65 64 20 74 |ough we |locked t| |00003120| 68 65 20 70 69 78 65 6c | 73 2c 20 77 65 20 64 69 |he pixel|s, we di| |00003130| 64 6e d5 74 20 6c 6f 63 | 6b 20 74 68 65 20 70 69 |dn.t loc|k the pi| |00003140| 78 4d 61 70 48 61 6e 64 | 6c 65 2c 20 73 6f 20 6e |xMapHand|le, so n| |00003150| 6f 20 6f 70 65 72 61 74 | 69 6f 6e 20 74 68 61 74 |o operat|ion that| |00003160| 20 63 6f 75 6c 64 20 6d | 6f 76 65 20 6d 65 6d 6f | could m|ove memo| |00003170| 72 79 20 69 73 20 70 65 | 72 66 6f 72 6d 65 64 2e |ry is pe|rformed.| |00003180| 20 59 6f 75 20 6d 75 73 | 74 20 62 65 20 63 61 72 | You mus|t be car| |00003190| 65 66 75 6c 20 74 68 61 | 74 20 74 68 65 20 67 65 |eful tha|t the ge| |000031a0| 74 20 61 6e 64 20 73 65 | 74 20 70 69 78 65 6c 20 |t and se|t pixel | |000031b0| 72 6f 75 74 69 6e 65 73 | 20 61 72 65 20 69 6e 20 |routines| are in | |000031c0| 74 68 65 20 73 61 6d 65 | 20 73 65 67 6d 65 6e 74 |the same| segment| |000031d0| 20 61 73 20 74 68 65 20 | 63 6f 64 65 20 74 68 61 | as the |code tha| |000031e0| 74 d5 73 20 63 61 6c 6c | 69 6e 67 20 74 68 65 6d |t.s call|ing them| |000031f0| 2c 20 6f 72 20 74 68 65 | 20 53 65 67 6d 65 6e 74 |, or the| Segment| |00003200| 20 4c 6f 61 64 65 72 20 | 6d 69 67 68 74 20 6d 6f | Loader |might mo| |00003210| 76 65 20 6d 65 6d 6f 72 | 79 20 77 68 65 6e 20 74 |ve memor|y when t| |00003220| 68 65 20 72 6f 75 74 69 | 6e 65 73 20 61 72 65 20 |he routi|nes are | |00003230| 63 61 6c 6c 65 64 2e 20 | 49 66 20 61 6c 6c 20 74 |called. |If all t| |00003240| 68 65 73 65 20 72 65 73 | 74 72 69 63 74 69 6f 6e |hese res|triction| |00003250| 73 20 61 72 65 20 74 6f | 6f 20 6d 75 63 68 20 74 |s are to|o much t| |00003260| 6f 20 6b 65 65 70 20 69 | 6e 20 6d 69 6e 64 2c 20 |o keep i|n mind, | |00003270| 73 69 6d 70 6c 79 20 63 | 61 6c 6c 20 48 4c 6f 63 |simply c|all HLoc| |00003280| 6b 20 6f 6e 20 74 68 65 | 20 70 69 78 4d 61 70 48 |k on the| pixMapH| |00003290| 61 6e 64 6c 65 2c 20 61 | 6e 64 20 74 68 65 6e 20 |andle, a|nd then | |000032a0| 48 55 6e 6c 6f 63 6b 20 | 77 68 65 6e 20 79 6f 75 |HUnlock |when you| |000032b0| d5 76 65 20 66 69 6e 69 | 73 68 65 64 2e 0d 4f 75 |.ve fini|shed..Ou| |000032c0| 72 20 73 61 6d 70 6c 65 | 20 69 6d 61 67 65 20 6e |r sample| image n| |000032d0| 6f 77 20 74 61 6b 65 73 | 20 6f 6e 6c 79 20 31 37 |ow takes| only 17| |000032e0| 20 74 69 63 6b 73 20 74 | 6f 20 70 72 6f 63 65 73 | ticks t|o proces| |000032f0| 73 2c 20 6f 72 20 61 62 | 6f 75 74 20 2e 33 20 73 |s, or ab|out .3 s| |00003300| 65 63 6f 6e 64 2e 20 54 | 68 69 73 20 69 73 20 61 |econd. T|his is a| |00003310| 20 6e 65 61 72 6c 79 20 | 33 37 2d 66 6f 6c 64 20 | nearly |37-fold | |00003320| 69 6d 70 72 6f 76 65 6d | 65 6e 74 20 6f 76 65 72 |improvem|ent over| |00003330| 20 74 68 65 20 66 69 72 | 73 74 20 76 65 72 73 69 | the fir|st versi| |00003340| 6f 6e 2e 20 42 75 74 20 | 77 65 d5 72 65 20 6e 6f |on. But |we.re no| |00003350| 74 20 64 6f 6e 65 20 79 | 65 74 2e 20 0d 41 6e 64 |t done y|et. .And| |00003360| 20 65 76 65 6e 20 66 61 | 73 74 65 72 2e 20 57 65 | even fa|ster. We| |00003370| d5 72 65 20 73 74 69 6c | 6c 20 70 65 72 66 6f 72 |.re stil|l perfor| |00003380| 6d 69 6e 67 20 74 77 6f | 20 73 75 62 72 6f 75 74 |ming two| subrout| |00003390| 69 6e 65 20 63 61 6c 6c | 73 20 61 6e 64 20 74 77 |ine call|s and tw| |000033a0| 6f 20 6d 75 6c 74 69 70 | 6c 69 65 73 20 70 65 72 |o multip|lies per| |000033b0| 20 70 69 78 65 6c 2c 20 | 61 20 6d 61 6a 6f 72 20 | pixel, |a major | |000033c0| 69 6e 65 66 66 69 63 69 | 65 6e 63 79 2e 20 54 68 |ineffici|ency. Th| |000033d0| 65 20 52 65 64 47 72 65 | 65 6e 49 6e 76 65 72 74 |e RedGre|enInvert| |000033e0| 20 72 6f 75 74 69 6e 65 | 20 67 65 74 73 20 72 69 | routine| gets ri| |000033f0| 64 20 6f 66 20 74 68 69 | 73 20 69 6e 65 66 66 69 |d of thi|s ineffi| |00003400| 63 69 65 6e 63 79 20 62 | 79 20 77 61 6c 6b 69 6e |ciency b|y walkin| |00003410| 67 20 61 20 47 57 6f 72 | 6c 64 d5 73 20 70 69 78 |g a GWor|ld.s pix| |00003420| 4d 61 70 20 74 6f 20 69 | 6e 76 65 72 74 20 74 68 |Map to i|nvert th| |00003430| 65 20 72 65 64 20 61 6e | 64 20 67 72 65 65 6e 20 |e red an|d green | |00003440| 63 68 61 6e 6e 65 6c 73 | 2e 0d 52 65 64 47 72 65 |channels|..RedGre| |00003450| 65 6e 49 6e 76 65 72 74 | 28 47 57 6f 72 6c 64 50 |enInvert|(GWorldP| |00003460| 74 72 20 73 72 63 29 0d | 7b 0d 50 69 78 4d 61 70 |tr src).|{.PixMap| |00003470| 48 61 6e 64 6c 65 09 73 | 72 63 50 69 78 4d 61 70 |Handle.s|rcPixMap| |00003480| 3b 0d 73 68 6f 72 74 09 | 09 09 73 72 63 52 6f 77 |;.short.|..srcRow| |00003490| 42 79 74 65 73 3b 0d 6c | 6f 6e 67 09 09 09 09 2a |Bytes;.l|ong....*| |000034a0| 73 72 63 42 61 73 65 41 | 64 64 72 3b 0d 6c 6f 6e |srcBaseA|ddr;.lon| |000034b0| 67 09 09 09 09 2a 73 72 | 63 41 64 64 72 31 3b 0d |g....*sr|cAddr1;.| |000034c0| 63 68 61 72 09 09 09 09 | 6d 6d 75 4d 6f 64 65 3b |char....|mmuMode;| |000034d0| 0d 73 68 6f 72 74 09 09 | 09 72 6f 77 2c 20 63 6f |.short..|.row, co| |000034e0| 6c 75 6d 6e 3b 0d 73 68 | 6f 72 74 09 09 09 77 69 |lumn;.sh|ort...wi| |000034f0| 64 74 68 2c 20 68 65 69 | 67 68 74 3b 0d 09 73 72 |dth, hei|ght;..sr| |00003500| 63 50 69 78 4d 61 70 20 | 3d 20 47 65 74 47 57 6f |cPixMap |= GetGWo| |00003510| 72 6c 64 50 69 78 4d 61 | 70 28 73 72 63 29 3b 0d |rldPixMa|p(src);.| |00003520| 09 69 66 28 4c 6f 63 6b | 50 69 78 65 6c 73 28 73 |.if(Lock|Pixels(s| |00003530| 72 63 50 69 78 4d 61 70 | 29 29 0d 09 7b 0d 09 09 |rcPixMap|))..{...| |00003540| 2f 2a 20 47 65 74 20 74 | 68 65 20 62 61 73 65 20 |/* Get t|he base | |00003550| 61 64 64 72 65 73 73 2e | 20 2a 2f 0d 09 09 73 72 |address.| */...sr| |00003560| 63 42 61 73 65 41 64 64 | 72 20 3d 20 28 6c 6f 6e |cBaseAdd|r = (lon| |00003570| 67 20 2a 29 20 47 65 74 | 50 69 78 42 61 73 65 41 |g *) Get|PixBaseA| |00003580| 64 64 72 28 73 72 63 50 | 69 78 4d 61 70 29 3b 0d |ddr(srcP|ixMap);.| |00003590| 0d 09 09 2f 2a 20 47 65 | 74 20 74 68 65 20 72 6f |.../* Ge|t the ro| |000035a0| 77 20 69 6e 63 72 65 6d | 65 6e 74 2e 20 2a 2f 0d |w increm|ent. */.| |000035b0| 09 09 73 72 63 52 6f 77 | 42 79 74 65 73 20 3d 20 |..srcRow|Bytes = | |000035c0| 28 2a 2a 73 72 63 50 69 | 78 4d 61 70 29 2e 72 6f |(**srcPi|xMap).ro| |000035d0| 77 42 79 74 65 73 20 26 | 20 30 78 37 66 66 66 3b |wBytes &| 0x7fff;| |000035e0| 0d 09 09 77 69 64 74 68 | 20 3d 20 28 2a 2a 73 72 |...width| = (**sr| |000035f0| 63 50 69 78 4d 61 70 29 | 2e 62 6f 75 6e 64 73 2e |cPixMap)|.bounds.| |00003600| 72 69 67 68 74 2d 28 2a | 2a 73 72 63 50 69 78 4d |right-(*|*srcPixM| |00003610| 61 70 29 2e 62 6f 75 6e | 64 73 2e 6c 65 66 74 3b |ap).boun|ds.left;| |00003620| 0d 09 09 68 65 69 67 68 | 74 20 3d 20 28 2a 2a 73 |...heigh|t = (**s| |00003630| 72 63 50 69 78 4d 61 70 | 29 2e 62 6f 75 6e 64 73 |rcPixMap|).bounds| |00003640| 2e 62 6f 74 74 6f 6d 2d | 28 2a 2a 73 72 63 50 69 |.bottom-|(**srcPi| |00003650| 78 4d 61 70 29 2e 62 6f | 75 6e 64 73 2e 74 6f 70 |xMap).bo|unds.top| |00003660| 3b 0d 09 09 6d 6d 75 4d | 6f 64 65 20 3d 20 74 72 |;...mmuM|ode = tr| |00003670| 75 65 33 32 62 3b 0d 09 | 09 53 77 61 70 4d 4d 55 |ue32b;..|.SwapMMU| |00003680| 4d 6f 64 65 28 26 6d 6d | 75 4d 6f 64 65 29 3b 09 |Mode(&mm|uMode);.| |00003690| 09 09 2f 2a 20 53 65 74 | 20 74 68 65 20 4d 4d 55 |../* Set| the MMU| |000036a0| 20 74 6f 20 33 32 2d 62 | 69 74 20 6d 6f 64 65 2e | to 32-b|it mode.| |000036b0| 20 2a 2f 0d 09 09 66 6f | 72 20 28 72 6f 77 20 3d | */...fo|r (row =| |000036c0| 20 30 3b 20 72 6f 77 20 | 3c 20 68 65 69 67 68 74 | 0; row |< height| |000036d0| 3b 20 72 6f 77 2b 2b 29 | 20 0d 09 09 7b 0d 09 09 |; row++)| ...{...| |000036e0| 09 73 72 63 41 64 64 72 | 31 20 3d 20 73 72 63 42 |.srcAddr|1 = srcB| |000036f0| 61 73 65 41 64 64 72 3b | 0d 09 09 09 66 6f 72 20 |aseAddr;|....for | |00003700| 28 63 6f 6c 75 6d 6e 20 | 3d 20 30 3b 20 63 6f 6c |(column |= 0; col| |00003710| 75 6d 6e 20 3c 20 77 69 | 64 74 68 3b 20 63 6f 6c |umn < wi|dth; col| |00003720| 75 6d 6e 2b 2b 29 0d 09 | 09 09 7b 0d 09 09 09 09 |umn++)..|..{.....| |00003730| 2f 2a 20 49 6e 76 65 72 | 74 20 74 68 65 20 72 65 |/* Inver|t the re| |00003740| 64 20 61 6e 64 20 67 72 | 65 65 6e 2e 20 4e 6f 74 |d and gr|een. Not| |00003750| 65 20 74 68 61 74 20 66 | 6f 72 20 33 32 2d 62 69 |e that f|or 32-bi| |00003760| 74 20 70 69 78 65 6c 73 | 2c 20 0d 09 09 09 09 09 |t pixels|, ......| |00003770| 70 69 78 65 6c 20 6d 65 | 6d 6f 72 79 20 69 73 20 |pixel me|mory is | |00003780| 6f 72 67 61 6e 69 7a 65 | 64 20 61 73 20 58 52 47 |organize|d as XRG| |00003790| 42 2c 20 77 68 65 72 65 | 20 65 61 63 68 20 63 6f |B, where| each co| |000037a0| 6d 70 6f 6e 65 6e 74 20 | 69 73 20 0d 09 09 09 09 |mponent |is .....| |000037b0| 09 38 20 62 69 74 73 2e | 20 2a 2f 0d 09 09 09 09 |.8 bits.| */.....| |000037c0| 2a 73 72 63 41 64 64 72 | 31 2b 2b 20 5e 3d 20 30 |*srcAddr|1++ ^= 0| |000037d0| 78 30 30 66 66 66 66 30 | 30 3b 09 09 2f 2a 20 42 |x00ffff0|0;../* B| |000037e0| 75 6d 70 20 74 6f 20 6e | 65 78 74 20 70 69 78 65 |ump to n|ext pixe| |000037f0| 6c 2e 20 2a 2f 0d 09 09 | 09 7d 0d 09 09 09 2f 2a |l. */...|.}..../*| |00003800| 20 47 6f 20 74 6f 20 74 | 68 65 20 6e 65 78 74 20 | Go to t|he next | |00003810| 72 6f 77 2e 20 2a 2f 0d | 09 09 09 73 72 63 42 61 |row. */.|...srcBa| |00003820| 73 65 41 64 64 72 20 3d | 20 28 6c 6f 6e 67 20 2a |seAddr =| (long *| |00003830| 29 20 28 28 63 68 61 72 | 20 2a 29 20 73 72 63 42 |) ((char| *) srcB| |00003840| 61 73 65 41 64 64 72 20 | 2b 20 73 72 63 52 6f 77 |aseAddr |+ srcRow| |00003850| 42 79 74 65 73 29 3b 0d | 09 09 7d 0d 09 09 53 77 |Bytes);.|..}...Sw| |00003860| 61 70 4d 4d 55 4d 6f 64 | 65 28 26 6d 6d 75 4d 6f |apMMUMod|e(&mmuMo| |00003870| 64 65 29 3b 09 09 2f 2a | 20 52 65 73 74 6f 72 65 |de);../*| Restore| |00003880| 20 74 68 65 20 70 72 65 | 76 69 6f 75 73 20 4d 4d | the pre|vious MM| |00003890| 55 20 6d 6f 64 65 2e 20 | 2a 2f 0d 09 09 55 6e 6c |U mode. |*/...Unl| |000038a0| 6f 63 6b 50 69 78 65 6c | 73 28 73 72 63 50 69 78 |ockPixel|s(srcPix| |000038b0| 4d 61 70 29 3b 09 2f 2a | 20 55 6e 6c 6f 63 6b 20 |Map);./*| Unlock | |000038c0| 74 68 65 20 70 69 78 4d | 61 70 2e 20 2a 2f 0d 09 |the pixM|ap. */..| |000038d0| 7d 0d 7d 0d 55 73 69 6e | 67 20 74 68 65 20 52 65 |}.}.Usin|g the Re| |000038e0| 64 47 72 65 65 6e 49 6e | 76 65 72 74 20 72 6f 75 |dGreenIn|vert rou| |000038f0| 74 69 6e 65 2c 20 6f 75 | 72 20 73 61 6d 70 6c 65 |tine, ou|r sample| |00003900| 20 69 6d 61 67 65 20 6e | 6f 77 20 74 61 6b 65 73 | image n|ow takes| |00003910| 20 31 20 74 69 63 6b 20 | 6f 72 20 31 2f 36 30 74 | 1 tick |or 1/60t| |00003920| 68 20 6f 66 20 61 20 73 | 65 63 6f 6e 64 20 74 6f |h of a s|econd to| |00003930| 20 70 72 6f 63 65 73 73 | 2e 20 54 68 69 73 20 69 | process|. This i| |00003940| 73 20 6e 65 61 72 6c 79 | 20 36 32 34 20 74 69 6d |s nearly| 624 tim| |00003950| 65 73 20 66 61 73 74 65 | 72 20 74 68 61 6e 20 74 |es faste|r than t| |00003960| 68 65 20 6f 72 69 67 69 | 6e 61 6c 20 76 65 72 73 |he origi|nal vers| |00003970| 69 6f 6e 21 20 45 76 65 | 6e 20 67 72 65 61 74 65 |ion! Eve|n greate| |00003980| 72 20 70 65 72 66 6f 72 | 6d 61 6e 63 65 20 67 61 |r perfor|mance ga| |00003990| 69 6e 73 20 63 61 6e 20 | 62 65 20 6d 61 64 65 20 |ins can |be made | |000039a0| 62 79 20 72 65 77 72 69 | 74 69 6e 67 20 74 68 69 |by rewri|ting thi| |000039b0| 73 20 72 6f 75 74 69 6e | 65 20 69 6e 20 61 73 73 |s routin|e in ass| |000039c0| 65 6d 62 6c 79 2c 20 62 | 75 74 20 74 68 61 74 d5 |embly, b|ut that.| |000039d0| 73 20 6c 65 66 74 20 61 | 73 20 61 6e 20 65 78 65 |s left a|s an exe| |000039e0| 72 63 69 73 65 20 66 6f | 72 20 79 6f 75 2e 0d 54 |rcise fo|r you..T| |000039f0| 68 65 20 70 72 69 63 65 | 20 79 6f 75 20 70 61 79 |he price| you pay| |00003a00| 2e 20 4e 6f 74 65 20 74 | 68 61 74 20 61 73 20 70 |. Note t|hat as p| |00003a10| 65 72 66 6f 72 6d 61 6e | 63 65 20 69 6e 63 72 65 |erforman|ce incre| |00003a20| 61 73 65 73 2c 20 74 68 | 65 20 66 6c 65 78 69 62 |ases, th|e flexib| |00003a30| 69 6c 69 74 79 20 6f 66 | 20 74 68 65 20 63 6f 64 |ility of| the cod| |00003a40| 65 20 64 65 63 72 65 61 | 73 65 73 2e 20 49 6e 20 |e decrea|ses. In | |00003a50| 6f 75 72 20 65 78 61 6d | 70 6c 65 2c 20 74 68 65 |our exam|ple, the| |00003a60| 20 6f 72 69 67 69 6e 61 | 6c 20 76 65 72 73 69 6f | origina|l versio| |00003a70| 6e 20 6f 66 20 74 68 65 | 20 63 6f 64 65 2c 20 77 |n of the| code, w| |00003a80| 68 69 63 68 20 63 61 6c | 6c 73 20 47 65 74 43 50 |hich cal|ls GetCP| |00003a90| 69 78 65 6c 20 61 6e 64 | 20 53 65 74 43 50 69 78 |ixel and| SetCPix| |00003aa0| 65 6c 2c 20 77 6f 72 6b | 73 20 66 6f 72 20 61 6c |el, work|s for al| |00003ab0| 6c 20 70 69 78 65 6c 20 | 64 65 70 74 68 73 2c 20 |l pixel |depths, | |00003ac0| 69 73 20 72 65 63 6f 72 | 64 65 64 20 69 6e 74 6f |is recor|ded into| |00003ad0| 20 70 69 63 74 75 72 65 | 73 2c 20 61 6e 64 20 64 | picture|s, and d| |00003ae0| 6f 65 73 20 74 68 65 20 | 61 63 74 75 61 6c 20 64 |oes the |actual d| |00003af0| 72 61 77 69 6e 67 20 75 | 73 69 6e 67 20 51 75 69 |rawing u|sing Qui| |00003b00| 63 6b 44 72 61 77 2e 20 | 47 57 53 65 74 33 32 50 |ckDraw. |GWSet32P| |00003b10| 69 78 65 6c 43 20 77 6f | 72 6b 73 20 6f 6e 6c 79 |ixelC wo|rks only| |00003b20| 20 6f 6e 20 33 32 2d 62 | 69 74 20 6f 66 66 2d 73 | on 32-b|it off-s| |00003b30| 63 72 65 65 6e 20 70 69 | 78 4d 61 70 73 2e 20 46 |creen pi|xMaps. F| |00003b40| 61 73 74 47 57 53 65 74 | 33 32 50 69 78 65 6c 20 |astGWSet|32Pixel | |00003b50| 68 61 73 20 74 68 65 20 | 61 64 64 69 74 69 6f 6e |has the |addition| |00003b60| 61 6c 20 72 65 73 74 72 | 69 63 74 69 6f 6e 20 74 |al restr|iction t| |00003b70| 68 61 74 20 69 74 20 68 | 61 73 20 74 6f 20 62 65 |hat it h|as to be| |00003b80| 20 63 61 6c 6c 65 64 20 | 69 6e 20 33 32 2d 62 69 | called |in 32-bi| |00003b90| 74 20 61 64 64 72 65 73 | 73 69 6e 67 20 6d 6f 64 |t addres|sing mod| |00003ba0| 65 2e 20 41 6e 64 20 66 | 69 6e 61 6c 6c 79 2c 20 |e. And f|inally, | |00003bb0| 52 65 64 47 72 65 65 6e | 49 6e 76 65 72 74 20 70 |RedGreen|Invert p| |00003bc0| 65 72 66 6f 72 6d 73 20 | 6f 6e 6c 79 20 6f 6e 65 |erforms |only one| |00003bd0| 20 73 70 65 63 69 66 69 | 63 20 6f 70 65 72 61 74 | specifi|c operat| |00003be0| 69 6f 6e 20 6f 6e 20 61 | 6e 20 65 6e 74 69 72 65 |ion on a|n entire| |00003bf0| 20 33 32 2d 62 69 74 20 | 47 57 6f 72 6c 64 2e 0d | 32-bit |GWorld..| |00003c00| 57 65 d5 76 65 20 73 68 | 6f 77 6e 20 79 6f 75 20 |We.ve sh|own you | |00003c10| 74 68 65 20 74 72 65 6d | 65 6e 64 6f 75 73 20 73 |the trem|endous s| |00003c20| 70 65 65 64 20 69 6d 70 | 72 6f 76 65 6d 65 6e 74 |peed imp|rovement| |00003c30| 73 20 79 6f 75 20 63 61 | 6e 20 61 63 68 69 65 76 |s you ca|n achiev| |00003c40| 65 20 62 79 20 77 72 69 | 74 69 6e 67 20 63 75 73 |e by wri|ting cus| |00003c50| 74 6f 6d 20 64 72 61 77 | 69 6e 67 20 72 6f 75 74 |tom draw|ing rout| |00003c60| 69 6e 65 73 2e 20 4e 6f | 77 20 77 65 20 74 75 72 |ines. No|w we tur| |00003c70| 6e 20 6f 75 72 20 61 74 | 74 65 6e 74 69 6f 6e 20 |n our at|tention | |00003c80| 74 6f 20 73 6f 6d 65 20 | 75 73 65 66 75 6c 20 63 |to some |useful c| |00003c90| 6f 64 65 20 65 78 61 6d | 70 6c 65 73 20 66 6f 72 |ode exam|ples for| |00003ca0| 20 6d 61 6e 69 70 75 6c | 61 74 69 6e 67 20 69 6d | manipul|ating im| |00003cb0| 61 67 65 73 2e 0d 43 55 | 53 54 4f 4d 20 44 52 41 |ages..CU|STOM DRA| |00003cc0| 57 49 4e 47 20 52 4f 55 | 54 49 4e 45 53 20 54 4f |WING ROU|TINES TO| |00003cd0| 20 4d 41 4e 49 50 55 4c | 41 54 45 20 49 4d 41 47 | MANIPUL|ATE IMAG| |00003ce0| 45 53 0d 53 6f 6d 65 20 | 69 6d 61 67 65 20 74 72 |ES.Some |image tr| |00003cf0| 61 6e 73 66 6f 72 6d 61 | 74 69 6f 6e 73 20 6c 65 |ansforma|tions le| |00003d00| 6e 64 20 74 68 65 6d 73 | 65 6c 76 65 73 20 74 6f |nd thems|elves to| |00003d10| 20 64 69 72 65 63 74 20 | 6d 61 6e 69 70 75 6c 61 | direct |manipula| |00003d20| 74 69 6f 6e 20 6f 66 20 | 47 57 6f 72 6c 64 20 64 |tion of |GWorld d| |00003d30| 61 74 61 2e 20 46 6f 72 | 20 65 78 61 6d 70 6c 65 |ata. For| example| |00003d40| 2c 20 77 69 74 68 20 63 | 75 73 74 6f 6d 20 64 72 |, with c|ustom dr| |00003d50| 61 77 69 6e 67 20 72 6f | 75 74 69 6e 65 73 20 77 |awing ro|utines w| |00003d60| 65 20 63 61 6e 20 74 72 | 61 6e 73 66 6f 72 6d 20 |e can tr|ansform | |00003d70| 69 6d 61 67 65 73 20 6f | 66 66 2d 73 63 72 65 65 |images o|ff-scree| |00003d80| 6e 20 69 6e 20 76 61 72 | 69 6f 75 73 20 77 61 79 |n in var|ious way| |00003d90| 73 2c 20 66 69 6e 64 20 | 74 68 65 20 65 64 67 65 |s, find |the edge| |00003da0| 73 20 6f 66 20 61 6e 20 | 69 6d 61 67 65 2c 20 71 |s of an |image, q| |00003db0| 75 69 63 6b 6c 79 20 73 | 63 61 6c 65 20 61 6e 20 |uickly s|cale an | |00003dc0| 69 6d 61 67 65 20 66 6f | 72 20 75 73 65 20 61 73 |image fo|r use as| |00003dd0| 20 61 20 6d 61 73 6b 2c | 20 61 6e 64 20 66 69 6c | a mask,| and fil| |00003de0| 6c 20 61 20 72 65 63 74 | 61 6e 67 6c 65 20 69 6e |l a rect|angle in| |00003df0| 20 72 65 61 6c 20 74 69 | 6d 65 2e 20 57 65 20 70 | real ti|me. We p| |00003e00| 72 65 73 65 6e 74 20 74 | 68 65 73 65 20 63 75 73 |resent t|hese cus| |00003e10| 74 6f 6d 20 72 6f 75 74 | 69 6e 65 73 20 68 65 72 |tom rout|ines her| |00003e20| 65 20 61 6e 64 20 6f 6e | 20 74 68 65 20 44 65 76 |e and on| the Dev| |00003e30| 65 6c 6f 70 65 72 20 43 | 44 20 53 65 72 69 65 73 |eloper C|D Series| |00003e40| 20 64 69 73 63 2e 0d 41 | 20 43 75 73 74 6f 6d 20 | disc..A| Custom | |00003e50| 52 6f 75 74 69 6e 65 20 | 74 6f 20 54 72 61 6e 73 |Routine |to Trans| |00003e60| 66 6f 72 6d 20 49 6d 61 | 67 65 73 0d 57 65 20 63 |form Ima|ges.We c| |00003e70| 61 6e 20 6f 62 74 61 69 | 6e 20 61 20 76 61 72 69 |an obtai|n a vari| |00003e80| 65 74 79 20 6f 66 20 73 | 70 65 63 69 61 6c 20 65 |ety of s|pecial e| |00003e90| 66 66 65 63 74 73 d1 69 | 6e 63 6c 75 64 69 6e 67 |ffects.i|ncluding| |00003ea0| 20 72 6f 74 61 74 69 6f | 6e 2c 20 73 74 72 65 74 | rotatio|n, stret| |00003eb0| 63 68 69 6e 67 2c 20 70 | 65 72 73 70 65 63 74 69 |ching, p|erspecti| |00003ec0| 76 65 20 74 72 61 6e 73 | 66 6f 72 6d 61 74 69 6f |ve trans|formatio| |00003ed0| 6e 2c 20 61 6e 64 20 73 | 69 6e 65 20 77 61 76 65 |n, and s|ine wave| |00003ee0| 20 77 61 72 70 69 6e 67 | d1 62 79 20 61 70 70 6c | warping|.by appl| |00003ef0| 79 69 6e 67 20 61 20 6d | 61 70 70 69 6e 67 20 6d |ying a m|apping m| |00003f00| 61 74 72 69 78 20 74 6f | 20 61 20 73 6f 75 72 63 |atrix to| a sourc| |00003f10| 65 20 47 57 6f 72 6c 64 | 2c 20 72 65 73 75 6c 74 |e GWorld|, result| |00003f20| 69 6e 67 20 69 6e 20 61 | 20 74 72 61 6e 73 66 6f |ing in a| transfo| |00003f30| 72 6d 65 64 20 64 65 73 | 74 69 6e 61 74 69 6f 6e |rmed des|tination| |00003f40| 20 47 57 6f 72 6c 64 2e | 20 54 68 69 73 20 74 65 | GWorld.| This te| |00003f50| 63 68 6e 69 71 75 65 20 | 72 65 71 75 69 72 65 73 |chnique |requires| |00003f60| 20 75 73 20 74 6f 20 61 | 63 63 65 73 73 20 61 6e | us to a|ccess an| |00003f70| 20 69 6d 61 67 65 20 61 | 74 20 66 72 61 63 74 69 | image a|t fracti| |00003f80| 6f 6e 61 6c 20 72 61 74 | 68 65 72 20 74 68 61 6e |onal rat|her than| |00003f90| 20 69 6e 74 65 67 65 72 | 20 70 69 78 65 6c 20 63 | integer| pixel c| |00003fa0| 6f 6f 72 64 69 6e 61 74 | 65 73 d1 74 68 61 74 20 |oordinat|es.that | |00003fb0| 69 73 2c 20 74 6f 20 64 | 6f 20 73 75 62 70 69 78 |is, to d|o subpix| |00003fc0| 65 6c 20 73 61 6d 70 6c | 69 6e 67 20 72 61 74 68 |el sampl|ing rath| |00003fd0| 65 72 20 74 68 61 6e 20 | 70 6f 69 6e 74 20 73 61 |er than |point sa| |00003fe0| 6d 70 6c 69 6e 67 2e 20 | 4c 65 74 d5 73 20 63 6f |mpling. |Let.s co| |00003ff0| 6e 73 69 64 65 72 20 73 | 75 62 70 69 78 65 6c 20 |nsider s|ubpixel | |00004000| 73 61 6d 70 6c 69 6e 67 | 20 66 69 72 73 74 20 61 |sampling| first a| |00004010| 6e 64 20 74 68 65 6e 20 | 6c 6f 6f 6b 20 61 74 20 |nd then |look at | |00004020| 74 68 65 20 6d 61 70 70 | 69 6e 67 20 72 6f 75 74 |the mapp|ing rout| |00004030| 69 6e 65 2e 0d 53 75 62 | 70 69 78 65 6c 20 73 61 |ine..Sub|pixel sa| |00004040| 6d 70 6c 69 6e 67 2e 20 | 49 6e 20 51 75 69 63 6b |mpling. |In Quick| |00004050| 44 72 61 77 2c 20 70 69 | 78 65 6c 73 20 61 72 65 |Draw, pi|xels are| |00004060| 20 64 65 66 69 6e 65 64 | 20 6f 6e 6c 79 20 66 6f | defined| only fo| |00004070| 72 20 69 6e 74 65 67 65 | 72 20 63 6f 6f 72 64 69 |r intege|r coordi| |00004080| 6e 61 74 65 73 20 61 6e | 64 20 75 6e 64 65 66 69 |nates an|d undefi| |00004090| 6e 65 64 20 65 6c 73 65 | 77 68 65 72 65 2e 20 54 |ned else|where. T| |000040a0| 68 65 20 6c 6f 63 61 74 | 69 6f 6e 20 6f 66 20 65 |he locat|ion of e| |000040b0| 61 63 68 20 70 69 78 65 | 6c 20 69 73 20 64 65 66 |ach pixe|l is def| |000040c0| 69 6e 65 64 20 62 79 20 | 74 68 65 20 70 61 69 72 |ined by |the pair| |000040d0| 20 6f 66 20 69 6e 74 65 | 67 65 72 20 63 6f 6f 72 | of inte|ger coor| |000040e0| 64 69 6e 61 74 65 73 20 | 61 74 20 69 74 73 20 75 |dinates |at its u| |000040f0| 70 70 65 72 20 6c 65 66 | 74 20 63 6f 72 6e 65 72 |pper lef|t corner| |00004100| 2e 20 54 6f 20 64 65 74 | 65 72 6d 69 6e 65 20 74 |. To det|ermine t| |00004110| 68 65 20 76 61 6c 75 65 | 20 61 20 70 69 78 65 6c |he value| a pixel| |00004120| 20 68 61 73 20 61 74 20 | 61 20 66 72 61 63 74 69 | has at |a fracti| |00004130| 6f 6e 61 6c 20 6c 6f 63 | 61 74 69 6f 6e 20 69 6e |onal loc|ation in| |00004140| 20 74 68 65 20 70 69 78 | 4d 61 70 2c 20 77 65 20 | the pix|Map, we | |00004150| 6d 75 73 74 20 75 73 65 | 20 61 20 66 69 6c 74 65 |must use| a filte| |00004160| 72 20 66 75 6e 63 74 69 | 6f 6e 2e 20 54 68 65 20 |r functi|on. The | |00004170| 72 6f 75 74 69 6e 65 20 | 77 65 20 70 72 6f 76 69 |routine |we provi| |00004180| 64 65 20 74 6f 20 64 6f | 20 73 75 62 70 69 78 65 |de to do| subpixe| |00004190| 6c 20 73 61 6d 70 6c 69 | 6e 67 2c 20 63 61 6c 6c |l sampli|ng, call| |000041a0| 65 64 20 47 65 74 46 72 | 61 63 74 69 6f 6e 61 6c |ed GetFr|actional| |000041b0| 50 69 78 65 6c 2c 20 63 | 61 6e 20 75 73 65 20 65 |Pixel, c|an use e| |000041c0| 69 74 68 65 72 20 6f 66 | 20 74 77 6f 20 74 79 70 |ither of| two typ| |000041d0| 65 73 20 6f 66 20 66 69 | 6c 74 65 72 73 3a 20 61 |es of fi|lters: a| |000041e0| 20 62 6f 78 20 66 69 6c | 74 65 72 20 6f 72 20 61 | box fil|ter or a| |000041f0| 20 74 65 6e 74 20 66 69 | 6c 74 65 72 2e 20 49 66 | tent fi|lter. If| |00004200| 20 75 73 65 5f 62 6f 78 | 5f 66 69 6c 74 65 72 20 | use_box|_filter | |00004210| 69 73 20 64 65 66 69 6e | 65 64 20 69 6e 20 74 68 |is defin|ed in th| |00004220| 65 20 47 65 74 46 72 61 | 63 74 69 6f 6e 61 6c 50 |e GetFra|ctionalP| |00004230| 69 78 65 6c 20 72 6f 75 | 74 69 6e 65 2c 20 61 20 |ixel rou|tine, a | |00004240| 62 6f 78 20 66 69 6c 74 | 65 72 20 69 73 20 75 73 |box filt|er is us| |00004250| 65 64 3b 20 6f 74 68 65 | 72 77 69 73 65 20 61 20 |ed; othe|rwise a | |00004260| 74 65 6e 74 20 66 69 6c | 74 65 72 20 69 73 20 75 |tent fil|ter is u| |00004270| 73 65 64 2e 0d 48 65 72 | 65 d5 73 20 68 6f 77 20 |sed..Her|e.s how | |00004280| 74 68 65 20 66 69 6c 74 | 65 72 73 20 77 6f 72 6b |the filt|ers work| |00004290| 2e 20 53 75 70 70 6f 73 | 65 20 74 68 65 20 67 72 |. Suppos|e the gr| |000042a0| 69 64 20 77 69 74 68 20 | 63 6f 72 6e 65 72 73 20 |id with |corners | |000042b0| 61 74 20 28 30 2c 30 29 | 20 61 6e 64 20 28 36 2c |at (0,0)| and (6,| |000042c0| 34 29 20 72 65 70 72 65 | 73 65 6e 74 73 20 70 61 |4) repre|sents pa| |000042d0| 72 74 20 6f 66 20 61 6e | 20 69 6d 61 67 65 2c 20 |rt of an| image, | |000042e0| 77 68 69 63 68 20 77 65 | 20 77 61 6e 74 20 74 6f |which we| want to| |000042f0| 20 73 61 6d 70 6c 65 20 | 61 74 20 66 72 61 63 74 | sample |at fract| |00004300| 69 6f 6e 61 6c 20 70 6f | 73 69 74 69 6f 6e 20 28 |ional po|sition (| |00004310| 32 2e 36 36 37 2c 31 2e | 37 35 29 2e 20 57 65 20 |2.667,1.|75). We | |00004320| 63 61 6e 20 76 69 73 75 | 61 6c 69 7a 65 20 65 61 |can visu|alize ea| |00004330| 63 68 20 66 69 6c 74 65 | 72 20 61 73 20 61 20 67 |ch filte|r as a g| |00004340| 65 6f 6d 65 74 72 69 63 | 20 73 6f 6c 69 64 20 77 |eometric| solid w| |00004350| 68 6f 73 65 20 62 61 73 | 65 20 63 6f 76 65 72 73 |hose bas|e covers| |00004360| 20 74 68 65 20 70 69 78 | 65 6c 28 73 29 20 6f 6e | the pix|el(s) on| |00004370| 20 74 68 65 20 67 72 69 | 64 20 74 6f 20 62 65 20 | the gri|d to be | |00004380| 73 61 6d 70 6c 65 64 20 | 61 6e 64 20 77 68 6f 73 |sampled |and whos| |00004390| 65 20 68 65 69 67 68 74 | 20 72 65 70 72 65 73 65 |e height| represe| |000043a0| 6e 74 73 20 74 68 65 20 | 77 65 69 67 68 74 20 74 |nts the |weight t| |000043b0| 6f 20 61 73 73 69 67 6e | 20 74 6f 20 74 68 65 20 |o assign| to the | |000043c0| 73 61 6d 70 6c 65 64 20 | 70 69 78 65 6c 28 73 29 |sampled |pixel(s)| |000043d0| 2e 20 0d 54 68 65 20 62 | 6f 78 20 66 69 6c 74 65 |. .The b|ox filte| |000043e0| 72 20 63 61 6e 20 62 65 | 20 76 69 73 75 61 6c 69 |r can be| visuali| |000043f0| 7a 65 64 20 61 73 20 61 | 20 31 2d 70 69 78 65 6c |zed as a| 1-pixel| |00004400| 20 78 20 31 2d 70 69 78 | 65 6c 20 78 20 31 2d 70 | x 1-pix|el x 1-p| |00004410| 69 78 65 6c 20 63 75 62 | 65 20 74 68 61 74 20 77 |ixel cub|e that w| |00004420| 65 20 70 6c 6f 70 20 64 | 6f 77 6e 20 6f 6e 20 74 |e plop d|own on t| |00004430| 68 65 20 67 72 69 64 20 | 77 69 74 68 20 69 74 73 |he grid |with its| |00004440| 20 62 6f 74 74 6f 6d 20 | 72 69 67 68 74 20 63 6f | bottom |right co| |00004450| 72 6e 65 72 20 61 74 20 | 74 68 65 20 66 72 61 63 |rner at |the frac| |00004460| 74 69 6f 6e 61 6c 20 63 | 6f 6f 72 64 69 6e 61 74 |tional c|oordinat| |00004470| 65 73 2c 20 61 73 20 73 | 68 6f 77 6e 20 69 6e 20 |es, as s|hown in | |00004480| 46 69 67 75 72 65 20 32 | 2e 20 54 68 65 20 62 6f |Figure 2|. The bo| |00004490| 78 20 66 69 6c 74 65 72 | 20 6d 65 72 65 6c 79 20 |x filter| merely | |000044a0| 63 68 6f 6f 73 65 73 20 | 74 68 65 20 76 61 6c 75 |chooses |the valu| |000044b0| 65 20 6f 66 20 74 68 65 | 20 70 69 78 65 6c 20 77 |e of the| pixel w| |000044c0| 68 6f 73 65 20 69 6e 74 | 65 67 65 72 20 63 6f 6f |hose int|eger coo| |000044d0| 72 64 69 6e 61 74 65 73 | 20 61 72 65 20 63 6f 76 |rdinates| are cov| |000044e0| 65 72 65 64 20 62 79 20 | 69 74 73 20 62 61 73 65 |ered by |its base| |000044f0| d1 69 6e 20 74 68 69 73 | 20 63 61 73 65 20 28 32 |.in this| case (2| |00004500| 2c 31 29 d1 61 6e 64 20 | 67 69 76 65 73 20 74 68 |,1).and |gives th| |00004510| 69 73 20 76 61 6c 75 65 | 20 61 20 77 65 69 67 68 |is value| a weigh| |00004520| 74 20 6f 66 20 31 2c 20 | 73 69 6e 63 65 20 74 68 |t of 1, |since th| |00004530| 65 20 62 6f 78 20 69 73 | 20 31 20 70 69 78 65 6c |e box is| 1 pixel| |00004540| 20 68 69 67 68 20 61 62 | 6f 76 65 20 74 68 65 20 | high ab|ove the | |00004550| 69 6e 74 65 67 65 72 20 | 63 6f 6f 72 64 69 6e 61 |integer |coordina| |00004560| 74 65 73 2e 20 54 68 69 | 73 20 76 61 6c 75 65 20 |tes. Thi|s value | |00004570| 69 73 20 74 68 65 6e 20 | 75 73 65 64 20 74 6f 20 |is then |used to | |00004580| 72 65 70 72 65 73 65 6e | 74 20 74 68 65 20 69 6d |represen|t the im| |00004590| 61 67 65 20 61 74 20 74 | 68 65 20 72 65 71 75 65 |age at t|he reque| |000045a0| 73 74 65 64 20 66 72 61 | 63 74 69 6f 6e 61 6c 20 |sted fra|ctional | |000045b0| 70 6f 73 69 74 69 6f 6e | 2e 20 0d 57 68 69 6c 65 |position|. .While| |000045c0| 20 74 68 65 20 62 6f 78 | 20 66 69 6c 74 65 72 20 | the box| filter | |000045d0| 74 61 6b 65 73 20 74 68 | 65 20 76 61 6c 75 65 20 |takes th|e value | |000045e0| 6f 66 20 6f 6e 65 20 69 | 6e 74 65 67 65 72 20 70 |of one i|nteger p| |000045f0| 69 78 65 6c 20 6c 6f 63 | 61 74 69 6f 6e 20 69 6e |ixel loc|ation in| |00004600| 20 74 68 65 20 73 6f 75 | 72 63 65 20 74 6f 20 72 | the sou|rce to r| |00004610| 65 70 72 65 73 65 6e 74 | 20 61 20 66 72 61 63 74 |epresent| a fract| |00004620| 69 6f 6e 61 6c 20 70 69 | 78 65 6c 20 6c 6f 63 61 |ional pi|xel loca| |00004630| 74 69 6f 6e 2c 20 74 68 | 65 20 74 65 6e 74 20 66 |tion, th|e tent f| |00004640| 69 6c 74 65 72 20 61 76 | 65 72 61 67 65 73 20 74 |ilter av|erages t| |00004650| 68 65 20 77 65 69 67 68 | 74 65 64 20 76 61 6c 75 |he weigh|ted valu| |00004660| 65 73 20 6f 66 20 75 70 | 20 74 6f 20 66 6f 75 72 |es of up| to four| |00004670| 20 61 64 6a 61 63 65 6e | 74 20 70 69 78 65 6c 73 | adjacen|t pixels| |00004680| 20 69 6e 20 74 68 65 20 | 73 6f 75 72 63 65 20 74 | in the |source t| |00004690| 6f 20 72 65 70 72 65 73 | 65 6e 74 20 61 20 66 72 |o repres|ent a fr| |000046a0| 61 63 74 69 6f 6e 61 6c | 20 70 69 78 65 6c 20 6c |actional| pixel l| |000046b0| 6f 63 61 74 69 6f 6e 2e | 20 54 68 65 20 74 65 6e |ocation.| The ten| |000046c0| 74 20 66 69 6c 74 65 72 | 20 63 61 6e 20 62 65 20 |t filter| can be | |000046d0| 76 69 73 75 61 6c 69 7a | 65 64 20 61 73 20 61 20 |visualiz|ed as a | |000046e0| 74 65 6e 74 20 77 69 74 | 68 20 61 20 32 2d 70 69 |tent wit|h a 2-pi| |000046f0| 78 65 6c 2d 73 71 75 61 | 72 65 20 62 61 73 65 20 |xel-squa|re base | |00004700| 74 68 61 74 20 77 65 20 | 70 6c 6f 70 20 64 6f 77 |that we |plop dow| |00004710| 6e 20 6f 6e 20 74 68 65 | 20 67 72 69 64 20 77 69 |n on the| grid wi| |00004720| 74 68 20 74 68 65 20 65 | 78 61 63 74 20 63 65 6e |th the e|xact cen| |00004730| 74 65 72 20 6f 66 20 69 | 74 73 20 62 61 73 65 20 |ter of i|ts base | |00004740| 61 74 20 74 68 65 20 66 | 72 61 63 74 69 6f 6e 61 |at the f|ractiona| |00004750| 6c 20 63 6f 6f 72 64 69 | 6e 61 74 65 73 2c 20 61 |l coordi|nates, a| |00004760| 73 20 73 68 6f 77 6e 20 | 69 6e 20 46 69 67 75 72 |s shown |in Figur| |00004770| 65 20 33 2e 20 54 68 65 | 20 74 65 6e 74 20 66 69 |e 3. The| tent fi| |00004780| 6c 74 65 72 20 74 61 6b | 65 73 20 74 68 65 20 76 |lter tak|es the v| |00004790| 61 6c 75 65 73 20 6f 66 | 20 74 68 65 20 6f 6e 65 |alues of| the one| |000047a0| 2c 20 74 77 6f 2c 20 6f | 72 20 66 6f 75 72 20 70 |, two, o|r four p| |000047b0| 69 78 65 6c 73 20 77 68 | 6f 73 65 20 69 6e 74 65 |ixels wh|ose inte| |000047c0| 67 65 72 20 63 6f 6f 72 | 64 69 6e 61 74 65 73 20 |ger coor|dinates | |000047d0| 61 72 65 20 63 6f 76 65 | 72 65 64 20 62 79 20 69 |are cove|red by i| |000047e0| 74 73 20 62 61 73 65 d1 | 69 6e 20 74 68 69 73 20 |ts base.|in this | |000047f0| 63 61 73 65 20 28 32 2c | 31 29 2c 20 28 33 2c 31 |case (2,|1), (3,1| |00004800| 29 2c 20 28 32 2c 32 29 | 2c 20 61 6e 64 20 28 33 |), (2,2)|, and (3| |00004810| 2c 32 29 d1 61 6e 64 20 | 67 69 76 65 73 20 65 61 |,2).and |gives ea| |00004820| 63 68 20 76 61 6c 75 65 | 20 61 20 64 69 66 66 65 |ch value| a diffe| |00004830| 72 65 6e 74 20 77 65 69 | 67 68 74 2e 20 41 73 20 |rent wei|ght. As | |00004840| 77 69 74 68 20 74 68 65 | 20 62 6f 78 20 66 69 6c |with the| box fil| |00004850| 74 65 72 2c 20 74 68 65 | 20 77 65 69 67 68 74 69 |ter, the| weighti| |00004860| 6e 67 20 66 6f 72 20 65 | 61 63 68 20 76 61 6c 75 |ng for e|ach valu| |00004870| 65 20 69 73 20 64 65 74 | 65 72 6d 69 6e 65 64 20 |e is det|ermined | |00004880| 62 79 20 74 68 65 20 68 | 65 69 67 68 74 20 6f 66 |by the h|eight of| |00004890| 20 74 68 65 20 73 6f 6c | 69 64 20 61 62 6f 76 65 | the sol|id above| |000048a0| 20 65 61 63 68 20 69 6e | 74 65 67 65 72 20 70 69 | each in|teger pi| |000048b0| 78 65 6c 20 63 6f 6f 72 | 64 69 6e 61 74 65 2e 20 |xel coor|dinate. | |000048c0| 54 68 65 20 61 76 65 72 | 61 67 65 20 6f 66 20 74 |The aver|age of t| |000048d0| 68 65 73 65 20 77 65 69 | 67 68 74 65 64 20 76 61 |hese wei|ghted va| |000048e0| 6c 75 65 73 20 69 73 20 | 74 68 65 6e 20 75 73 65 |lues is |then use| |000048f0| 64 20 74 6f 20 72 65 70 | 72 65 73 65 6e 74 20 74 |d to rep|resent t| |00004900| 68 65 20 69 6d 61 67 65 | 20 61 74 20 74 68 65 20 |he image| at the | |00004910| 72 65 71 75 65 73 74 65 | 64 20 66 72 61 63 74 69 |requeste|d fracti| |00004920| 6f 6e 61 6c 20 70 6f 73 | 69 74 69 6f 6e 2e 20 0d |onal pos|ition. .| |00004930| 0d 0d 46 69 67 75 72 65 | 20 32 0d 53 75 62 70 69 |..Figure| 2.Subpi| |00004940| 78 65 6c 20 53 61 6d 70 | 6c 69 6e 67 20 55 73 69 |xel Samp|ling Usi| |00004950| 6e 67 20 61 20 42 6f 78 | 20 46 69 6c 74 65 72 0d |ng a Box| Filter.| |00004960| 46 69 67 75 72 65 20 33 | 0d 53 75 62 70 69 78 65 |Figure 3|.Subpixe| |00004970| 6c 20 53 61 6d 70 6c 69 | 6e 67 20 55 73 69 6e 67 |l Sampli|ng Using| |00004980| 20 61 20 54 65 6e 74 20 | 46 69 6c 74 65 72 0d 4e | a Tent |Filter.N| |00004990| 6f 74 65 20 69 6e 20 46 | 69 67 75 72 65 20 33 20 |ote in F|igure 3 | |000049a0| 74 68 61 74 20 74 68 65 | 20 65 64 67 65 20 66 72 |that the| edge fr| |000049b0| 6f 6d 20 74 68 65 20 63 | 65 6e 74 65 72 20 6f 66 |om the c|enter of| |000049c0| 20 74 68 65 20 73 69 64 | 65 20 6f 66 20 74 68 65 | the sid|e of the| |000049d0| 20 74 65 6e 74 20 62 61 | 73 65 20 74 6f 20 74 68 | tent ba|se to th| |000049e0| 65 20 74 6f 70 20 69 73 | 20 6c 69 6e 65 61 72 20 |e top is| linear | |000049f0| 28 7a 20 3d 20 78 29 2c | 20 77 68 69 6c 65 20 74 |(z = x),| while t| |00004a00| 68 65 20 65 64 67 65 20 | 66 72 6f 6d 20 74 68 65 |he edge |from the| |00004a10| 20 63 6f 72 6e 65 72 20 | 6f 66 20 74 68 65 20 74 | corner |of the t| |00004a20| 65 6e 74 20 62 61 73 65 | 20 74 6f 20 74 68 65 20 |ent base| to the | |00004a30| 74 6f 70 20 69 73 20 71 | 75 61 64 72 61 74 69 63 |top is q|uadratic| |00004a40| 20 28 7a 20 3d 20 78 32 | 29 2e 20 4e 6f 74 65 20 | (z = x2|). Note | |00004a50| 61 6c 73 6f 20 74 68 61 | 74 20 69 6e 20 74 77 6f |also tha|t in two| |00004a60| 20 64 69 6d 65 6e 73 69 | 6f 6e 73 20 6f 75 72 20 | dimensi|ons our | |00004a70| 74 65 6e 74 20 66 69 6c | 74 65 72 20 69 73 20 65 |tent fil|ter is e| |00004a80| 71 75 69 76 61 6c 65 6e | 74 20 74 6f 20 69 6d 70 |quivalen|t to imp| |00004a90| 6f 73 69 6e 67 20 6f 6e | 20 74 68 65 20 67 72 69 |osing on| the gri| |00004aa0| 64 20 61 20 70 69 78 65 | 6c 20 77 69 74 68 20 69 |d a pixe|l with i| |00004ab0| 74 73 20 75 70 70 65 72 | 20 6c 65 66 74 20 63 6f |ts upper| left co| |00004ac0| 72 6e 65 72 20 61 74 20 | 74 68 65 20 66 72 61 63 |rner at |the frac| |00004ad0| 74 69 6f 6e 61 6c 20 6c | 6f 63 61 74 69 6f 6e 2c |tional l|ocation,| |00004ae0| 20 63 61 6c 63 75 6c 61 | 74 69 6e 67 20 77 68 61 | calcula|ting wha| |00004af0| 74 20 70 65 72 63 65 6e | 74 61 67 65 20 6f 66 20 |t percen|tage of | |00004b00| 65 61 63 68 20 6f 66 20 | 66 6f 75 72 20 69 6e 74 |each of |four int| |00004b10| 65 67 65 72 20 63 6f 6f | 72 64 69 6e 61 74 65 20 |eger coo|rdinate | |00004b20| 70 69 78 65 6c 73 20 69 | 74 20 6f 76 65 72 6c 61 |pixels i|t overla| |00004b30| 70 73 2c 20 6d 75 6c 74 | 69 70 6c 79 69 6e 67 20 |ps, mult|iplying | |00004b40| 74 68 65 20 76 61 6c 75 | 65 20 6f 66 20 65 61 63 |the valu|e of eac| |00004b50| 68 20 6f 76 65 72 6c 61 | 70 70 65 64 20 70 69 78 |h overla|pped pix| |00004b60| 65 6c 20 62 79 20 74 68 | 69 73 20 72 65 73 70 65 |el by th|is respe| |00004b70| 63 74 69 76 65 20 70 65 | 72 63 65 6e 74 61 67 65 |ctive pe|rcentage| |00004b80| 2c 20 61 6e 64 20 74 68 | 65 6e 20 61 76 65 72 61 |, and th|en avera| |00004b90| 67 69 6e 67 20 74 68 65 | 73 65 20 76 61 6c 75 65 |ging the|se value| |00004ba0| 73 2c 20 61 73 20 73 68 | 6f 77 6e 20 69 6e 20 46 |s, as sh|own in F| |00004bb0| 69 67 75 72 65 20 34 2e | 0d 54 68 65 20 62 6f 78 |igure 4.|.The box| |00004bc0| 20 66 69 6c 74 65 72 20 | 61 70 70 72 6f 78 69 6d | filter |approxim| |00004bd0| 61 74 69 6f 6e 20 6d 61 | 6b 65 73 20 74 68 65 20 |ation ma|kes the | |00004be0| 70 69 78 65 6c 20 76 61 | 6c 75 65 20 63 61 6c 63 |pixel va|lue calc| |00004bf0| 75 6c 61 74 69 6f 6e 20 | 65 61 73 79 2c 20 62 75 |ulation |easy, bu| |00004c00| 74 20 72 65 73 75 6c 74 | 73 20 69 6e 20 73 6f 6d |t result|s in som| |00004c10| 65 20 62 6c 75 72 72 69 | 6e 67 20 6f 66 20 74 68 |e blurri|ng of th| |00004c20| 65 20 69 6d 61 67 65 2e | 20 54 68 65 20 74 65 6e |e image.| The ten| |00004c30| 74 20 66 69 6c 74 65 72 | 20 70 72 6f 64 75 63 65 |t filter| produce| |00004c40| 73 20 6d 75 63 68 20 62 | 65 74 74 65 72 20 69 6d |s much b|etter im| |00004c50| 61 67 65 73 20 74 68 61 | 6e 20 74 68 65 20 62 6f |ages tha|n the bo| |00004c60| 78 20 66 69 6c 74 65 72 | 2c 20 62 75 74 20 74 68 |x filter|, but th| |00004c70| 65 20 63 61 6c 63 75 6c | 61 74 69 6f 6e 20 74 69 |e calcul|ation ti| |00004c80| 6d 65 20 66 6f 72 20 65 | 61 63 68 20 70 69 78 65 |me for e|ach pixe| |00004c90| 6c 20 69 73 20 63 6f 6e | 73 69 64 65 72 61 62 6c |l is con|siderabl| |00004ca0| 79 20 6c 6f 6e 67 65 72 | 2e 20 46 69 67 75 72 65 |y longer|. Figure| |00004cb0| 20 35 20 0d 0d 46 69 67 | 75 72 65 20 34 0d 54 77 | 5 ..Fig|ure 4.Tw| |00004cc0| 6f 2d 44 69 6d 65 6e 73 | 69 6f 6e 61 6c 20 45 71 |o-Dimens|ional Eq| |00004cd0| 75 69 76 61 6c 65 6e 74 | 20 6f 66 20 4f 75 72 20 |uivalent| of Our | |00004ce0| 54 65 6e 74 20 46 69 6c | 74 65 72 0d 20 20 20 20 |Tent Fil|ter. | |00004cf0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00004d00| 20 20 0d 09 54 65 6e 74 | 20 66 69 6c 74 65 72 20 | ..Tent| filter | |00004d10| 09 42 6f 78 20 66 69 6c | 74 65 72 0d 46 69 67 75 |.Box fil|ter.Figu| |00004d20| 72 65 20 35 0d 54 68 65 | 20 33 32 2d 42 69 74 20 |re 5.The| 32-Bit | |00004d30| 51 75 69 63 6b 44 72 61 | 77 20 49 63 6f 6e 2c 20 |QuickDra|w Icon, | |00004d40| 53 63 61 6c 65 64 20 57 | 69 74 68 20 61 20 54 65 |Scaled W|ith a Te| |00004d50| 6e 74 20 46 69 6c 74 65 | 72 20 56 65 72 73 75 73 |nt Filte|r Versus| |00004d60| 20 61 20 42 6f 78 20 46 | 69 6c 74 65 72 20 0d 69 | a Box F|ilter .i| |00004d70| 6c 6c 75 73 74 72 61 74 | 65 73 20 74 68 65 20 64 |llustrat|es the d| |00004d80| 69 66 66 65 72 65 6e 63 | 65 20 62 65 74 77 65 65 |ifferenc|e betwee| |00004d90| 6e 20 61 6e 20 69 6d 61 | 67 65 20 73 63 61 6c 65 |n an ima|ge scale| |00004da0| 64 20 77 69 74 68 20 61 | 20 74 65 6e 74 20 66 69 |d with a| tent fi| |00004db0| 6c 74 65 72 20 61 6e 64 | 20 77 69 74 68 20 61 20 |lter and| with a | |00004dc0| 62 6f 78 20 66 69 6c 74 | 65 72 2e 0d 54 68 65 20 |box filt|er..The | |00004dd0| 47 65 74 46 72 61 63 74 | 69 6f 6e 61 6c 50 69 78 |GetFract|ionalPix| |00004de0| 65 6c 20 72 6f 75 74 69 | 6e 65 20 64 6f 65 73 20 |el routi|ne does | |00004df0| 61 6c 6c 20 74 68 65 20 | 77 6f 72 6b 2e 20 54 68 |all the |work. Th| |00004e00| 65 20 63 6f 64 65 20 66 | 69 72 73 74 20 64 65 74 |e code f|irst det| |00004e10| 65 72 6d 69 6e 65 73 20 | 77 68 65 74 68 65 72 20 |ermines |whether | |00004e20| 74 68 65 20 72 65 71 75 | 65 73 74 65 64 20 70 69 |the requ|ested pi| |00004e30| 78 65 6c 20 6c 69 65 73 | 20 77 69 74 68 69 6e 20 |xel lies| within | |00004e40| 74 68 65 20 62 6f 75 6e | 64 73 20 6f 66 20 74 68 |the boun|ds of th| |00004e50| 65 20 73 6f 75 72 63 65 | 20 70 69 78 4d 61 70 20 |e source| pixMap | |00004e60| 61 6e 64 20 72 65 74 75 | 72 6e 73 20 66 61 6c 73 |and retu|rns fals| |00004e70| 65 20 69 66 20 69 74 20 | 64 6f 65 73 6e d5 74 2e |e if it |doesn.t.| |00004e80| 20 4e 65 78 74 2c 20 74 | 68 65 20 63 6f 64 65 20 | Next, t|he code | |00004e90| 74 72 75 6e 63 61 74 65 | 73 20 70 69 78 65 6c 73 |truncate|s pixels| |00004ea0| 20 74 68 61 74 20 6c 69 | 65 20 6f 66 66 20 74 68 | that li|e off th| |00004eb0| 65 20 72 69 67 68 74 20 | 6f 72 20 62 6f 74 74 6f |e right |or botto| |00004ec0| 6d 20 74 6f 20 66 69 74 | 20 77 68 6f 6c 6c 79 20 |m to fit| wholly | |00004ed0| 77 69 74 68 69 6e 20 74 | 68 65 20 73 6f 75 72 63 |within t|he sourc| |00004ee0| 65 2e 20 46 69 6e 61 6c | 6c 79 2c 20 74 68 65 20 |e. Final|ly, the | |00004ef0| 70 69 78 65 6c 73 20 74 | 6f 75 63 68 65 64 20 62 |pixels t|ouched b| |00004f00| 79 20 74 68 65 20 72 65 | 71 75 65 73 74 65 64 20 |y the re|quested | |00004f10| 6c 6f 63 61 74 69 6f 6e | 20 61 72 65 20 77 65 69 |location| are wei| |00004f20| 67 68 74 65 64 20 61 6e | 64 20 61 76 65 72 61 67 |ghted an|d averag| |00004f30| 65 64 20 28 64 65 70 65 | 6e 64 69 6e 67 20 6f 6e |ed (depe|nding on| |00004f40| 20 74 68 65 20 66 69 6c | 74 65 72 20 66 75 6e 63 | the fil|ter func| |00004f50| 74 69 6f 6e 29 20 61 6e | 64 20 74 68 65 20 72 65 |tion) an|d the re| |00004f60| 73 75 6c 74 20 69 73 20 | 72 65 74 75 72 6e 65 64 |sult is |returned| |00004f70| 2e 0d 73 74 61 74 69 63 | 20 42 6f 6f 6c 65 61 6e |..static| Boolean| |00004f80| 20 47 65 74 46 72 61 63 | 74 69 6f 6e 61 6c 50 69 | GetFrac|tionalPi| |00004f90| 78 65 6c 28 6c 6f 6e 67 | 20 2a 73 72 63 42 61 73 |xel(long| *srcBas| |00004fa0| 65 41 64 64 72 2c 20 6c | 6f 6e 67 20 73 72 63 52 |eAddr, l|ong srcR| |00004fb0| 6f 77 4c 6f 6e 67 73 2c | 0d 09 52 65 63 74 20 2a |owLongs,|..Rect *| |00004fc0| 73 72 63 42 6f 75 6e 64 | 73 2c 20 46 69 78 65 64 |srcBound|s, Fixed| |00004fd0| 20 66 78 2c 20 46 69 78 | 65 64 20 66 79 2c 20 6c | fx, Fix|ed fy, l| |00004fe0| 6f 6e 67 20 2a 64 73 74 | 4c 6f 6e 67 29 0d 7b 0d |ong *dst|Long).{.| |00004ff0| 75 6e 73 69 67 6e 65 64 | 20 6c 6f 6e 67 09 09 74 |unsigned| long..t| |00005000| 65 6d 70 42 6c 75 65 2c | 20 74 65 6d 70 47 72 65 |empBlue,| tempGre| |00005010| 65 6e 2c 20 74 65 6d 70 | 52 65 64 3b 0d 6c 6f 6e |en, temp|Red;.lon| |00005020| 67 09 09 09 09 09 73 72 | 63 50 69 78 65 6c 5b 32 |g.....sr|cPixel[2| |00005030| 5d 5b 32 5d 3b 0d 73 68 | 6f 72 74 46 72 61 63 09 |][2];.sh|ortFrac.| |00005040| 09 09 73 63 61 6c 65 5b | 32 5d 5b 32 5d 3b 0d 50 |..scale[|2][2];.P| |00005050| 6f 69 6e 74 09 09 09 09 | 70 3b 0d 09 53 65 74 50 |oint....|p;..SetP| |00005060| 74 28 26 70 2c 20 66 78 | 20 3e 3e 20 31 36 2c 20 |t(&p, fx| >> 16, | |00005070| 66 79 20 3e 3e 20 31 36 | 29 3b 0d 09 2f 2a 20 4d |fy >> 16|);../* M| |00005080| 6f 64 65 6c 65 73 73 50 | 74 49 6e 52 65 63 74 20 |odelessP|tInRect | |00005090| 69 73 20 61 20 76 65 72 | 73 69 6f 6e 20 6f 66 20 |is a ver|sion of | |000050a0| 51 75 69 63 6b 44 72 61 | 77 27 73 20 50 6f 69 6e |QuickDra|w's Poin| |000050b0| 74 49 6e 52 65 63 74 20 | 0d 09 09 72 6f 75 74 69 |tInRect |...routi| |000050c0| 6e 65 20 74 68 61 74 20 | 77 6f 72 6b 73 20 69 6e |ne that |works in| |000050d0| 20 65 69 74 68 65 72 20 | 32 34 2d 62 69 74 20 6f | either |24-bit o| |000050e0| 72 20 33 32 2d 62 69 74 | 20 61 64 64 72 65 73 73 |r 32-bit| address| |000050f0| 69 6e 67 20 6d 6f 64 65 | 2e 20 2a 2f 0d 09 69 66 |ing mode|. */..if| |00005100| 20 28 21 4d 6f 64 65 6c | 65 73 73 50 74 49 6e 52 | (!Model|essPtInR| |00005110| 65 63 74 28 70 2c 20 73 | 72 63 42 6f 75 6e 64 73 |ect(p, s|rcBounds| |00005120| 29 29 0d 09 09 72 65 74 | 75 72 6e 20 66 61 6c 73 |))...ret|urn fals| |00005130| 65 3b 0d 09 69 66 20 28 | 70 2e 68 20 3d 3d 20 73 |e;..if (|p.h == s| |00005140| 72 63 42 6f 75 6e 64 73 | 2d 3e 72 69 67 68 74 20 |rcBounds|->right | |00005150| 2d 20 31 29 0d 09 09 66 | 78 20 3d 20 66 66 28 70 |- 1)...f|x = ff(p| |00005160| 2e 68 29 3b 09 2f 2a 20 | 66 66 28 29 20 69 73 20 |.h);./* |ff() is | |00005170| 61 20 6d 61 63 72 6f 20 | 74 68 61 74 20 67 69 76 |a macro |that giv| |00005180| 65 6e 20 61 20 73 68 6f | 72 74 2c 20 0d 09 09 09 |en a sho|rt, ....| |00005190| 09 09 09 09 09 72 65 74 | 75 72 6e 73 20 61 20 66 |.....ret|urns a f| |000051a0| 69 78 65 64 2e 20 2a 2f | 0d 09 69 66 20 28 70 2e |ixed. */|..if (p.| |000051b0| 76 20 3d 3d 20 73 72 63 | 42 6f 75 6e 64 73 2d 3e |v == src|Bounds->| |000051c0| 62 6f 74 74 6f 6d 20 2d | 20 31 29 0d 09 09 66 79 |bottom -| 1)...fy| |000051d0| 20 3d 20 66 66 28 70 2e | 76 29 3b 0d 09 2f 2a 20 | = ff(p.|v);../* | |000051e0| 43 6f 6d 70 75 74 65 20 | 74 68 65 20 61 64 64 72 |Compute |the addr| |000051f0| 65 73 73 20 6f 66 20 74 | 68 65 20 66 69 72 73 74 |ess of t|he first| |00005200| 20 73 6f 75 72 63 65 20 | 70 69 78 65 6c 2e 20 2a | source |pixel. *| |00005210| 2f 0d 09 7b 0d 09 09 6c | 6f 6e 67 20 2a 73 72 63 |/..{...l|ong *src| |00005220| 41 64 64 72 20 3d 20 73 | 72 63 42 61 73 65 41 64 |Addr = s|rcBaseAd| |00005230| 64 72 20 2b 20 70 2e 76 | 20 2a 20 73 72 63 52 6f |dr + p.v| * srcRo| |00005240| 77 4c 6f 6e 67 73 20 2b | 20 70 2e 68 3b 0d 23 69 |wLongs +| p.h;.#i| |00005250| 66 20 75 73 65 5f 62 6f | 78 5f 66 69 6c 74 65 72 |f use_bo|x_filter| |00005260| 0d 09 09 2a 64 73 74 4c | 6f 6e 67 20 3d 20 2a 73 |...*dstL|ong = *s| |00005270| 72 63 41 64 64 72 3b 0d | 09 09 72 65 74 75 72 6e |rcAddr;.|..return| |00005280| 20 74 72 75 65 3b 0d 23 | 65 6e 64 69 66 0d 09 09 | true;.#|endif...| |00005290| 73 72 63 50 69 78 65 6c | 5b 30 5d 5b 30 5d 20 3d |srcPixel|[0][0] =| |000052a0| 20 2a 73 72 63 41 64 64 | 72 2b 2b 3b 0d 09 09 73 | *srcAdd|r++;...s| |000052b0| 72 63 50 69 78 65 6c 5b | 30 5d 5b 31 5d 20 3d 20 |rcPixel[|0][1] = | |000052c0| 2a 73 72 63 41 64 64 72 | 2b 2b 3b 0d 09 09 73 72 |*srcAddr|++;...sr| |000052d0| 63 41 64 64 72 20 2b 3d | 20 73 72 63 52 6f 77 4c |cAddr +=| srcRowL| |000052e0| 6f 6e 67 73 3b 0d 09 09 | 73 72 63 50 69 78 65 6c |ongs;...|srcPixel| |000052f0| 5b 31 5d 5b 31 5d 20 3d | 20 2a 2d 2d 73 72 63 41 |[1][1] =| *--srcA| |00005300| 64 64 72 3b 0d 09 09 73 | 72 63 50 69 78 65 6c 5b |ddr;...s|rcPixel[| |00005310| 31 5d 5b 30 5d 20 3d 20 | 2a 2d 2d 73 72 63 41 64 |1][0] = |*--srcAd| |00005320| 64 72 3b 0d 09 7d 0d 09 | 2f 2a 20 50 72 65 63 6f |dr;..}..|/* Preco| |00005330| 6d 70 75 74 65 20 74 68 | 65 20 73 63 61 6c 65 73 |mpute th|e scales| |00005340| 20 66 6f 72 20 65 61 63 | 68 20 70 69 78 65 6c 2e | for eac|h pixel.| |00005350| 20 53 68 6f 72 74 46 72 | 61 63 4d 75 6c 20 6d 75 | ShortFr|acMul mu| |00005360| 6c 74 69 70 6c 69 65 73 | 20 0d 09 09 74 77 6f 20 |ltiplies| ...two | |00005370| 73 68 6f 72 74 20 66 72 | 61 63 74 69 6f 6e 73 20 |short fr|actions | |00005380| 61 6e 64 20 72 65 74 75 | 72 6e 73 20 61 20 73 68 |and retu|rns a sh| |00005390| 6f 72 74 20 66 72 61 63 | 74 69 6f 6e 2e 20 2a 2f |ort frac|tion. */| |000053a0| 0d 09 7b 09 0d 09 09 73 | 68 6f 72 74 46 72 61 63 |..{....s|hortFrac| |000053b0| 20 78 46 72 61 63 20 3d | 20 46 69 78 65 64 32 53 | xFrac =| Fixed2S| |000053c0| 68 6f 72 74 46 72 61 63 | 28 28 75 6e 73 69 67 6e |hortFrac|((unsign| |000053d0| 65 64 20 73 68 6f 72 74 | 29 66 78 29 3b 0d 09 09 |ed short|)fx);...| |000053e0| 73 68 6f 72 74 46 72 61 | 63 20 79 46 72 61 63 20 |shortFra|c yFrac | |000053f0| 3d 20 46 69 78 65 64 32 | 53 68 6f 72 74 46 72 61 |= Fixed2|ShortFra| |00005400| 63 28 28 75 6e 73 69 67 | 6e 65 64 20 73 68 6f 72 |c((unsig|ned shor| |00005410| 74 29 66 79 29 3b 0d 09 | 0d 09 09 73 63 61 6c 65 |t)fy);..|...scale| |00005420| 5b 30 5d 5b 30 5d 20 3d | 20 53 68 6f 72 74 46 72 |[0][0] =| ShortFr| |00005430| 61 63 4d 75 6c 28 6f 6e | 65 53 68 6f 72 74 46 72 |acMul(on|eShortFr| |00005440| 61 63 20 2d 20 78 46 72 | 61 63 2c 20 0d 09 09 09 |ac - xFr|ac, ....| |00005450| 6f 6e 65 53 68 6f 72 74 | 46 72 61 63 20 2d 20 79 |oneShort|Frac - y| |00005460| 46 72 61 63 29 3b 0d 09 | 09 73 63 61 6c 65 5b 30 |Frac);..|.scale[0| |00005470| 5d 5b 31 5d 20 3d 20 53 | 68 6f 72 74 46 72 61 63 |][1] = S|hortFrac| |00005480| 4d 75 6c 28 78 46 72 61 | 63 2c 20 6f 6e 65 53 68 |Mul(xFra|c, oneSh| |00005490| 6f 72 74 46 72 61 63 20 | 2d 20 79 46 72 61 63 29 |ortFrac |- yFrac)| |000054a0| 3b 0d 09 09 73 63 61 6c | 65 5b 31 5d 5b 30 5d 20 |;...scal|e[1][0] | |000054b0| 3d 20 53 68 6f 72 74 46 | 72 61 63 4d 75 6c 28 6f |= ShortF|racMul(o| |000054c0| 6e 65 53 68 6f 72 74 46 | 72 61 63 20 2d 20 78 46 |neShortF|rac - xF| |000054d0| 72 61 63 2c 20 79 46 72 | 61 63 29 3b 0d 0d 09 09 |rac, yFr|ac);....| |000054e0| 73 63 61 6c 65 5b 31 5d | 5b 31 5d 20 3d 20 53 68 |scale[1]|[1] = Sh| |000054f0| 6f 72 74 46 72 61 63 4d | 75 6c 28 78 46 72 61 63 |ortFracM|ul(xFrac| |00005500| 2c 20 79 46 72 61 63 29 | 3b 0d 09 7d 0d 09 2f 2a |, yFrac)|;..}../*| |00005510| 20 4e 6f 77 20 73 63 61 | 6c 65 20 65 61 63 68 20 | Now sca|le each | |00005520| 63 6f 6d 70 6f 6e 65 6e | 74 20 6f 66 20 65 61 63 |componen|t of eac| |00005530| 68 20 63 6f 72 6e 65 72 | 20 62 79 20 74 68 65 20 |h corner| by the | |00005540| 70 65 72 63 65 6e 74 61 | 67 65 20 6f 66 20 74 68 |percenta|ge of th| |00005550| 65 20 0d 09 09 22 72 65 | 61 6c 22 20 70 69 78 65 |e ..."re|al" pixe| |00005560| 6c 20 63 6f 76 65 72 65 | 64 20 62 79 20 74 68 65 |l covere|d by the| |00005570| 20 66 72 61 63 74 69 6f | 6e 61 6c 20 70 69 78 65 | fractio|nal pixe| |00005580| 6c 20 28 74 68 65 20 61 | 72 65 61 20 63 6f 76 65 |l (the a|rea cove| |00005590| 72 65 64 0d 09 09 62 79 | 20 74 68 65 20 66 69 6c |red...by| the fil| |000055a0| 74 65 72 29 2e 20 2a 2f | 0d 09 74 65 6d 70 42 6c |ter). */|..tempBl| |000055b0| 75 65 20 3d 09 09 53 68 | 6f 72 74 46 72 61 63 4d |ue =..Sh|ortFracM| |000055c0| 75 6c 42 79 74 65 28 73 | 63 61 6c 65 5b 30 5d 5b |ulByte(s|cale[0][| |000055d0| 30 5d 2c 20 73 72 63 50 | 69 78 65 6c 5b 30 5d 5b |0], srcP|ixel[0][| |000055e0| 30 5d 29 20 2b 0d 09 09 | 09 09 09 09 53 68 6f 72 |0]) +...|....Shor| |000055f0| 74 46 72 61 63 4d 75 6c | 42 79 74 65 28 73 63 61 |tFracMul|Byte(sca| |00005600| 6c 65 5b 30 5d 5b 31 5d | 2c 20 73 72 63 50 69 78 |le[0][1]|, srcPix| |00005610| 65 6c 5b 30 5d 5b 31 5d | 29 20 2b 0d 09 09 09 09 |el[0][1]|) +.....| |00005620| 09 09 53 68 6f 72 74 46 | 72 61 63 4d 75 6c 42 79 |..ShortF|racMulBy| |00005630| 74 65 28 73 63 61 6c 65 | 5b 31 5d 5b 30 5d 2c 20 |te(scale|[1][0], | |00005640| 73 72 63 50 69 78 65 6c | 5b 31 5d 5b 30 5d 29 20 |srcPixel|[1][0]) | |00005650| 2b 0d 09 09 09 09 09 09 | 53 68 6f 72 74 46 72 61 |+.......|ShortFra| |00005660| 63 4d 75 6c 42 79 74 65 | 28 73 63 61 6c 65 5b 31 |cMulByte|(scale[1| |00005670| 5d 5b 31 5d 2c 20 73 72 | 63 50 69 78 65 6c 5b 31 |][1], sr|cPixel[1| |00005680| 5d 5b 31 5d 29 3b 0d 09 | 69 66 20 28 74 65 6d 70 |][1]);..|if (temp| |00005690| 42 6c 75 65 20 3d 3d 20 | 32 35 36 29 20 74 65 6d |Blue == |256) tem| |000056a0| 70 42 6c 75 65 20 3d 20 | 32 35 35 3b 0d 09 0d 09 |pBlue = |255;....| |000056b0| 74 65 6d 70 47 72 65 65 | 6e 20 3d 09 53 68 6f 72 |tempGree|n =.Shor| |000056c0| 74 46 72 61 63 4d 75 6c | 42 79 74 65 28 73 63 61 |tFracMul|Byte(sca| |000056d0| 6c 65 5b 30 5d 5b 30 5d | 2c 20 73 72 63 50 69 78 |le[0][0]|, srcPix| |000056e0| 65 6c 5b 30 5d 5b 30 5d | 20 3e 3e 20 38 29 20 2b |el[0][0]| >> 8) +| |000056f0| 0d 09 09 09 09 09 09 53 | 68 6f 72 74 46 72 61 63 |.......S|hortFrac| |00005700| 4d 75 6c 42 79 74 65 28 | 73 63 61 6c 65 5b 30 5d |MulByte(|scale[0]| |00005710| 5b 31 5d 2c 20 73 72 63 | 50 69 78 65 6c 5b 30 5d |[1], src|Pixel[0]| |00005720| 5b 31 5d 20 3e 3e 20 38 | 29 20 2b 0d 09 09 09 09 |[1] >> 8|) +.....| |00005730| 09 09 53 68 6f 72 74 46 | 72 61 63 4d 75 6c 42 79 |..ShortF|racMulBy| |00005740| 74 65 28 73 63 61 6c 65 | 5b 31 5d 5b 30 5d 2c 20 |te(scale|[1][0], | |00005750| 73 72 63 50 69 78 65 6c | 5b 31 5d 5b 30 5d 20 3e |srcPixel|[1][0] >| |00005760| 3e 20 38 29 20 2b 0d 09 | 09 09 09 09 09 53 68 6f |> 8) +..|.....Sho| |00005770| 72 74 46 72 61 63 4d 75 | 6c 42 79 74 65 28 73 63 |rtFracMu|lByte(sc| |00005780| 61 6c 65 5b 31 5d 5b 31 | 5d 2c 20 73 72 63 50 69 |ale[1][1|], srcPi| |00005790| 78 65 6c 5b 31 5d 5b 31 | 5d 20 3e 3e 20 38 29 3b |xel[1][1|] >> 8);| |000057a0| 0d 09 69 66 20 28 74 65 | 6d 70 47 72 65 65 6e 20 |..if (te|mpGreen | |000057b0| 3d 3d 20 32 35 36 29 20 | 74 65 6d 70 47 72 65 65 |== 256) |tempGree| |000057c0| 6e 20 3d 20 32 35 35 3b | 0d 09 0d 09 74 65 6d 70 |n = 255;|....temp| |000057d0| 52 65 64 20 3d 09 09 53 | 68 6f 72 74 46 72 61 63 |Red =..S|hortFrac| |000057e0| 4d 75 6c 42 79 74 65 28 | 73 63 61 6c 65 5b 30 5d |MulByte(|scale[0]| |000057f0| 5b 30 5d 2c 20 73 72 63 | 50 69 78 65 6c 5b 30 5d |[0], src|Pixel[0]| |00005800| 5b 30 5d 20 3e 3e 20 31 | 36 29 20 2b 0d 09 09 09 |[0] >> 1|6) +....| |00005810| 09 09 09 53 68 6f 72 74 | 46 72 61 63 4d 75 6c 42 |...Short|FracMulB| |00005820| 79 74 65 28 73 63 61 6c | 65 5b 30 5d 5b 31 5d 2c |yte(scal|e[0][1],| |00005830| 20 73 72 63 50 69 78 65 | 6c 5b 30 5d 5b 31 5d 20 | srcPixe|l[0][1] | |00005840| 3e 3e 20 31 36 29 20 2b | 0d 09 09 09 09 09 09 53 |>> 16) +|.......S| |00005850| 68 6f 72 74 46 72 61 63 | 4d 75 6c 42 79 74 65 28 |hortFrac|MulByte(| |00005860| 73 63 61 6c 65 5b 31 5d | 5b 30 5d 2c 20 73 72 63 |scale[1]|[0], src| |00005870| 50 69 78 65 6c 5b 31 5d | 5b 30 5d 20 3e 3e 20 31 |Pixel[1]|[0] >> 1| |00005880| 36 29 20 2b 0d 09 09 09 | 09 09 09 53 68 6f 72 74 |6) +....|...Short| |00005890| 46 72 61 63 4d 75 6c 42 | 79 74 65 28 73 63 61 6c |FracMulB|yte(scal| |000058a0| 65 5b 31 5d 5b 31 5d 2c | 20 73 72 63 50 69 78 65 |e[1][1],| srcPixe| |000058b0| 6c 5b 31 5d 5b 31 5d 20 | 3e 3e 20 31 36 29 3b 0d |l[1][1] |>> 16);.| |000058c0| 09 69 66 20 28 74 65 6d | 70 52 65 64 20 3d 3d 20 |.if (tem|pRed == | |000058d0| 32 35 36 29 20 74 65 6d | 70 52 65 64 20 3d 20 32 |256) tem|pRed = 2| |000058e0| 35 35 3b 0d 09 2a 64 73 | 74 4c 6f 6e 67 20 3d 20 |55;..*ds|tLong = | |000058f0| 28 74 65 6d 70 52 65 64 | 20 3c 3c 20 31 36 29 20 |(tempRed| << 16) | |00005900| 7c 20 28 74 65 6d 70 47 | 72 65 65 6e 20 3c 3c 20 || (tempG|reen << | |00005910| 38 29 20 7c 20 74 65 6d | 70 42 6c 75 65 3b 0d 09 |8) | tem|pBlue;..| |00005920| 72 65 74 75 72 6e 20 74 | 72 75 65 3b 0d 7d 0d 54 |return t|rue;.}.T| |00005930| 68 65 20 6d 61 70 70 69 | 6e 67 20 72 6f 75 74 69 |he mappi|ng routi| |00005940| 6e 65 2e 20 4f 75 72 20 | 63 75 73 74 6f 6d 20 72 |ne. Our |custom r| |00005950| 6f 75 74 69 6e 65 20 74 | 6f 20 74 72 61 6e 73 66 |outine t|o transf| |00005960| 6f 72 6d 20 69 6d 61 67 | 65 73 20 62 79 20 61 70 |orm imag|es by ap| |00005970| 70 6c 79 69 6e 67 20 61 | 20 6d 61 70 70 69 6e 67 |plying a| mapping| |00005980| 20 6d 61 74 72 69 78 20 | 6d 61 6b 65 73 20 75 73 | matrix |makes us| |00005990| 65 20 6f 66 20 74 68 65 | 20 47 65 74 46 72 61 63 |e of the| GetFrac| |000059a0| 74 69 6f 6e 61 6c 50 69 | 78 65 6c 20 72 6f 75 74 |tionalPi|xel rout| |000059b0| 69 6e 65 2e 20 54 68 65 | 20 6d 61 70 70 69 6e 67 |ine. The| mapping| |000059c0| 20 72 6f 75 74 69 6e 65 | 20 73 65 74 73 20 75 70 | routine| sets up| |000059d0| 20 61 20 6d 61 70 70 69 | 6e 67 20 6d 61 74 72 69 | a mappi|ng matri| |000059e0| 78 20 61 6e 64 20 74 68 | 65 6e 20 63 61 6c 6c 73 |x and th|en calls| |000059f0| 20 4d 61 70 47 57 6f 72 | 6c 64 2e 20 4d 61 70 47 | MapGWor|ld. MapG| |00005a00| 57 6f 72 6c 64 20 74 61 | 6b 65 73 20 61 20 47 57 |World ta|kes a GW| |00005a10| 6f 72 6c 64 20 61 6e 64 | 20 61 70 70 6c 69 65 73 |orld and| applies| |00005a20| 20 74 68 65 20 6d 61 70 | 70 69 6e 67 20 6d 61 74 | the map|ping mat| |00005a30| 72 69 78 20 74 6f 20 69 | 74 2c 20 72 65 73 75 6c |rix to i|t, resul| |00005a40| 74 69 6e 67 20 69 6e 20 | 61 20 74 72 61 6e 73 66 |ting in |a transf| |00005a50| 6f 72 6d 65 64 20 47 57 | 6f 72 6c 64 2e 20 4d 61 |ormed GW|orld. Ma| |00005a60| 70 47 57 6f 72 6c 64 20 | 61 6c 73 6f 20 74 61 6b |pGWorld |also tak| |00005a70| 65 73 20 61 20 56 41 52 | 20 6d 61 73 6b 20 70 61 |es a VAR| mask pa| |00005a80| 72 61 6d 65 74 65 72 2e | 20 49 66 20 74 68 69 73 |rameter.| If this| |00005a90| 20 70 61 72 61 6d 65 74 | 65 72 20 69 73 20 73 65 | paramet|er is se| |00005aa0| 74 20 74 6f 20 6e 69 6c | 2c 20 69 74 d5 73 20 75 |t to nil|, it.s u| |00005ab0| 6e 75 73 65 64 2e 20 4f | 74 68 65 72 77 69 73 65 |nused. O|therwise| |00005ac0| 2c 20 4d 61 70 47 57 6f | 72 6c 64 20 72 65 74 75 |, MapGWo|rld retu| |00005ad0| 72 6e 73 20 61 20 31 2d | 62 69 74 20 6d 61 73 6b |rns a 1-|bit mask| |00005ae0| 20 74 68 61 74 20 69 6e | 64 69 63 61 74 65 73 20 | that in|dicates | |00005af0| 77 68 69 63 68 20 64 65 | 73 74 69 6e 61 74 69 6f |which de|stinatio| |00005b00| 6e 20 70 69 78 65 6c 73 | 20 77 65 72 65 20 73 65 |n pixels| were se| |00005b10| 74 2e 20 54 68 69 73 20 | 6d 61 73 6b 20 63 61 6e |t. This |mask can| |00005b20| 20 62 65 20 70 61 73 73 | 65 64 20 61 73 20 61 20 | be pass|ed as a | |00005b30| 70 61 72 61 6d 65 74 65 | 72 20 74 6f 20 43 6f 70 |paramete|r to Cop| |00005b40| 79 4d 61 73 6b 20 6f 72 | 20 43 6f 70 79 44 65 65 |yMask or| CopyDee| |00005b50| 70 4d 61 73 6b 20 74 6f | 20 74 72 61 6e 73 66 65 |pMask to| transfe| |00005b60| 72 20 74 68 65 20 72 65 | 73 75 6c 74 73 20 6f 6e |r the re|sults on| |00005b70| 74 6f 20 74 68 65 20 73 | 63 72 65 65 6e 2e 0d 46 |to the s|creen..F| |00005b80| 69 67 75 72 65 20 36 20 | 64 69 61 67 72 61 6d 73 |igure 6 |diagrams| |00005b90| 20 68 6f 77 20 4d 61 70 | 47 57 6f 72 6c 64 20 77 | how Map|GWorld w| |00005ba0| 6f 72 6b 73 2e 20 54 68 | 65 20 6d 61 74 72 69 78 |orks. Th|e matrix| |00005bb0| 20 73 68 6f 77 6e 20 74 | 68 65 72 65 20 69 73 20 | shown t|here is | |00005bc0| 74 68 65 20 6f 6e 65 20 | 74 68 61 74 20 72 6f 74 |the one |that rot| |00005bd0| 61 74 65 73 20 61 6e 20 | 69 6d 61 67 65 20 33 35 |ates an |image 35| |00005be0| 20 64 65 67 72 65 65 73 | 20 66 72 6f 6d 20 74 68 | degrees| from th| |00005bf0| 65 20 78 2d 61 78 69 73 | 20 74 6f 77 61 72 64 20 |e x-axis| toward | |00005c00| 74 68 65 20 79 2d 61 78 | 69 73 2e 0d 73 74 61 74 |the y-ax|is..stat| |00005c10| 69 63 20 47 57 6f 72 6c | 64 50 74 72 20 4d 61 70 |ic GWorl|dPtr Map| |00005c20| 47 57 6f 72 6c 64 28 47 | 57 6f 72 6c 64 50 74 72 |GWorld(G|WorldPtr| |00005c30| 20 73 72 63 57 6f 72 6c | 64 2c 20 6d 61 70 70 69 | srcWorl|d, mappi| |00005c40| 6e 67 20 2a 64 73 74 4d | 61 70 70 69 6e 67 2c 0d |ng *dstM|apping,.| |00005c50| 09 47 57 6f 72 6c 64 50 | 74 72 20 2a 6d 61 73 6b |.GWorldP|tr *mask| |00005c60| 57 6f 72 6c 64 29 0d 7b | 0d 47 57 6f 72 6c 64 50 |World).{|.GWorldP| |00005c70| 74 72 09 09 09 64 73 74 | 57 6f 72 6c 64 3b 0d 50 |tr...dst|World;.P| |00005c80| 69 78 4d 61 70 48 61 6e | 64 6c 65 09 09 73 72 63 |ixMapHan|dle..src| |00005c90| 50 69 78 4d 61 70 2c 20 | 64 73 74 50 69 78 4d 61 |PixMap, |dstPixMa| |00005ca0| 70 3b 0d 0d 6c 6f 6e 67 | 09 09 09 2a 73 72 63 42 |p;..long|...*srcB| |00005cb0| 61 73 65 41 64 64 72 2c | 20 2a 64 73 74 42 61 73 |aseAddr,| *dstBas| |00005cc0| 65 41 64 64 72 2c 20 73 | 72 63 52 6f 77 4c 6f 6e |eAddr, s|rcRowLon| |00005cd0| 67 73 2c 20 64 73 74 52 | 6f 77 4c 6f 6e 67 73 3b |gs, dstR|owLongs;| |00005ce0| 0d 52 65 63 74 09 09 09 | 73 72 63 52 65 63 74 2c |.Rect...|srcRect,| |00005cf0| 20 64 73 74 52 65 63 74 | 3b 0d 6d 61 70 70 69 6e | dstRect|;.mappin| |00005d00| 67 09 09 69 6e 76 65 72 | 73 65 4d 61 70 70 69 6e |g..inver|seMappin| |00005d10| 67 3b 0d 63 68 61 72 09 | 09 09 78 2c 20 79 2c 20 |g;.char.|..x, y, | |00005d20| 6d 6d 75 4d 6f 64 65 3b | 0d 09 2f 2a 20 43 72 65 |mmuMode;|../* Cre| |00005d30| 61 74 65 20 74 68 65 20 | 64 73 74 57 6f 72 6c 64 |ate the |dstWorld| |00005d40| 20 73 69 7a 65 64 20 74 | 6f 20 68 6f 6c 64 20 74 | sized t|o hold t| |00005d50| 68 65 20 74 72 61 6e 73 | 66 6f 72 6d 65 64 20 73 |he trans|formed s| |00005d60| 72 63 57 6f 72 6c 64 2e | 20 2a 2f 0d 09 64 73 74 |rcWorld.| */..dst| |00005d70| 52 65 63 74 20 3d 20 73 | 72 63 52 65 63 74 20 3d |Rect = s|rcRect =| |00005d80| 20 73 72 63 57 6f 72 6c | 64 2d 3e 70 6f 72 74 52 | srcWorl|d->portR| |00005d90| 65 63 74 3b 0d 09 4d 61 | 70 52 65 63 74 61 6e 67 |ect;..Ma|pRectang| |00005da0| 6c 65 28 64 73 74 4d 61 | 70 70 69 6e 67 2c 20 26 |le(dstMa|pping, &| |00005db0| 64 73 74 52 65 63 74 29 | 3b 0d 09 69 66 20 28 4e |dstRect)|;..if (N| |00005dc0| 65 77 47 57 6f 72 6c 64 | 28 26 64 73 74 57 6f 72 |ewGWorld|(&dstWor| |00005dd0| 6c 64 2c 20 33 32 2c 20 | 26 64 73 74 52 65 63 74 |ld, 32, |&dstRect| |00005de0| 2c 20 30 2c 20 30 2c 20 | 30 29 29 0d 09 09 72 65 |, 0, 0, |0))...re| |00005df0| 74 75 72 6e 20 30 3b 0d | 09 2f 2a 20 4f 70 74 69 |turn 0;.|./* Opti| |00005e00| 6f 6e 61 6c 6c 79 2c 20 | 63 72 65 61 74 65 20 61 |onally, |create a| |00005e10| 20 6d 61 73 6b 57 6f 72 | 6c 64 20 77 69 74 68 20 | maskWor|ld with | |00005e20| 74 68 65 20 73 61 6d 65 | 20 62 6f 75 6e 64 73 20 |the same| bounds | |00005e30| 61 73 20 0d 09 09 74 68 | 65 20 64 73 74 57 6f 72 |as ...th|e dstWor| |00005e40| 6c 64 2e 20 2a 2f 0d 09 | 69 66 20 28 6d 61 73 6b |ld. */..|if (mask| |00005e50| 57 6f 72 6c 64 29 0d 09 | 7b 09 0d 09 09 69 66 20 |World)..|{....if | |00005e60| 28 4e 65 77 47 57 6f 72 | 6c 64 28 6d 61 73 6b 57 |(NewGWor|ld(maskW| |00005e70| 6f 72 6c 64 2c 20 31 2c | 20 26 64 73 74 52 65 63 |orld, 1,| &dstRec| |00005e80| 74 2c 20 30 2c 20 30 2c | 20 30 29 29 0d 09 09 7b |t, 0, 0,| 0))...{| |00005e90| 09 0d 09 09 09 44 69 73 | 70 6f 73 65 47 57 6f 72 |.....Dis|poseGWor| |00005ea0| 6c 64 28 64 73 74 57 6f | 72 6c 64 29 3b 0d 09 09 |ld(dstWo|rld);...| |00005eb0| 09 72 65 74 75 72 6e 20 | 30 3b 0d 09 09 7d 0d 09 |.return |0;...}..| |00005ec0| 09 45 72 61 73 65 47 57 | 6f 72 6c 64 28 2a 6d 61 |.EraseGW|orld(*ma| |00005ed0| 73 6b 57 6f 72 6c 64 2c | 20 26 64 73 74 52 65 63 |skWorld,| &dstRec| |00005ee0| 74 29 3b 0d 09 7d 0d 09 | 2f 2a 20 53 65 74 20 75 |t);..}..|/* Set u| |00005ef0| 70 20 66 6f 72 20 66 61 | 73 74 20 77 61 6c 6b 69 |p for fa|st walki| |00005f00| 6e 67 20 6f 66 20 74 68 | 65 20 73 72 63 20 61 6e |ng of th|e src an| |00005f10| 64 20 64 73 74 2e 20 4e | 65 65 64 20 74 6f 20 73 |d dst. N|eed to s| |00005f20| 77 61 70 20 0d 09 09 4d | 4d 55 20 6d 6f 64 65 20 |wap ...M|MU mode | |00005f30| 74 6f 20 6c 6f 6f 6b 20 | 61 74 20 74 68 65 20 62 |to look |at the b| |00005f40| 61 73 65 41 64 64 72 2e | 20 2a 2f 0d 09 73 72 63 |aseAddr.| */..src| |00005f50| 50 69 78 4d 61 70 20 3d | 20 47 65 74 47 57 6f 72 |PixMap =| GetGWor| |00005f60| 6c 64 50 69 78 4d 61 70 | 28 73 72 63 57 6f 72 6c |ldPixMap|(srcWorl| |00005f70| 64 29 3b 0d 09 64 73 74 | 50 69 78 4d 61 70 20 3d |d);..dst|PixMap =| |00005f80| 20 47 65 74 47 57 6f 72 | 6c 64 50 69 78 4d 61 70 | GetGWor|ldPixMap| |00005f90| 28 64 73 74 57 6f 72 6c | 64 29 3b 0d 09 2f 2a 20 |(dstWorl|d);../* | |00005fa0| 47 65 74 20 74 68 65 20 | 61 64 64 72 65 73 73 20 |Get the |address | |00005fb0| 6f 66 20 74 68 65 20 70 | 69 78 4d 61 70 2e 20 2a |of the p|ixMap. *| |00005fc0| 2f 0d 09 73 72 63 42 61 | 73 65 41 64 64 72 20 3d |/..srcBa|seAddr =| |00005fd0| 20 28 6c 6f 6e 67 20 2a | 29 20 47 65 74 50 69 78 | (long *|) GetPix| |00005fe0| 42 61 73 65 41 64 64 72 | 28 73 72 63 50 69 78 4d |BaseAddr|(srcPixM| |00005ff0| 61 70 29 3b 0d 09 2f 2a | 20 47 65 74 20 74 68 65 |ap);../*| Get the| |00006000| 20 72 6f 77 20 69 6e 63 | 72 65 6d 65 6e 74 2e 20 | row inc|rement. | |00006010| 2a 2f 0d 09 73 72 63 52 | 6f 77 4c 6f 6e 67 73 20 |*/..srcR|owLongs | |00006020| 3d 20 28 28 2a 2a 73 72 | 63 50 69 78 4d 61 70 29 |= ((**sr|cPixMap)| |00006030| 2e 72 6f 77 42 79 74 65 | 73 20 26 20 30 78 37 66 |.rowByte|s & 0x7f| |00006040| 66 66 29 20 3e 3e 20 32 | 3b 0d 09 2f 2a 20 47 65 |ff) >> 2|;../* Ge| |00006050| 74 20 74 68 65 20 61 64 | 64 72 65 73 73 20 6f 66 |t the ad|dress of| |00006060| 20 74 68 65 20 70 69 78 | 4d 61 70 2e 20 2a 2f 0d | the pix|Map. */.| |00006070| 09 64 73 74 42 61 73 65 | 41 64 64 72 20 3d 20 28 |.dstBase|Addr = (| |00006080| 6c 6f 6e 67 20 2a 29 20 | 47 65 74 50 69 78 42 61 |long *) |GetPixBa| |00006090| 73 65 41 64 64 72 28 64 | 73 74 50 69 78 4d 61 70 |seAddr(d|stPixMap| |000060a0| 29 3b 0d 09 2f 2a 20 47 | 65 74 20 74 68 65 20 72 |);../* G|et the r| |000060b0| 6f 77 20 69 6e 63 72 65 | 6d 65 6e 74 2e 20 2a 2f |ow incre|ment. */| |000060c0| 0d 09 64 73 74 52 6f 77 | 4c 6f 6e 67 73 20 3d 20 |..dstRow|Longs = | |000060d0| 28 28 2a 2a 64 73 74 50 | 69 78 4d 61 70 29 2e 72 |((**dstP|ixMap).r| |000060e0| 6f 77 42 79 74 65 73 20 | 26 20 30 78 37 66 66 66 |owBytes |& 0x7fff| |000060f0| 29 20 3e 3e 20 32 3b 0d | 09 69 6e 76 65 72 73 65 |) >> 2;.|.inverse| |00006100| 4d 61 70 70 69 6e 67 20 | 3d 20 2a 64 73 74 4d 61 |Mapping |= *dstMa| |00006110| 70 70 69 6e 67 3b 09 0d | 09 49 6e 76 65 72 74 4d |pping;..|.InvertM| |00006120| 61 70 70 69 6e 67 28 26 | 69 6e 76 65 72 73 65 4d |apping(&|inverseM| |00006130| 61 70 70 69 6e 67 29 3b | 0d 09 6d 6d 75 4d 6f 64 |apping);|..mmuMod| |00006140| 65 20 3d 20 74 72 75 65 | 20 33 32 62 3b 0d 09 53 |e = true| 32b;..S| |00006150| 77 61 70 4d 4d 55 4d 6f | 64 65 28 26 6d 6d 75 4d |wapMMUMo|de(&mmuM| |00006160| 6f 64 65 29 3b 09 09 2f | 2a 20 53 65 74 20 74 68 |ode);../|* Set th| |00006170| 65 20 4d 4d 55 20 74 6f | 20 33 32 2d 62 69 74 20 |e MMU to| 32-bit | |00006180| 6d 6f 64 65 2e 20 2a 2f | 0d 09 66 6f 72 20 28 79 |mode. */|..for (y| |00006190| 20 3d 20 64 73 74 52 65 | 63 74 2e 74 6f 70 3b 20 | = dstRe|ct.top; | |000061a0| 79 20 3c 20 64 73 74 52 | 65 63 74 2e 62 6f 74 74 |y < dstR|ect.bott| |000061b0| 6f 6d 3b 20 79 2b 2b 29 | 0d 09 7b 0d 09 09 6c 6f |om; y++)|..{...lo| |000061c0| 6e 67 20 2a 64 73 74 41 | 64 64 72 20 3d 20 64 73 |ng *dstA|ddr = ds| |000061d0| 74 42 61 73 65 41 64 64 | 72 3b 0d 09 09 66 6f 72 |tBaseAdd|r;...for| |000061e0| 20 28 78 20 3d 20 64 73 | 74 52 65 63 74 2e 6c 65 | (x = ds|tRect.le| |000061f0| 66 74 3b 20 78 20 3c 20 | 64 73 74 52 65 63 74 2e |ft; x < |dstRect.| |00006200| 72 69 67 68 74 3b 20 78 | 2b 2b 29 0d 09 09 7b 0d |right; x|++)...{.| |00006210| 09 09 09 46 69 78 65 64 | 20 73 72 63 58 20 3d 20 |...Fixed| srcX = | |00006220| 66 66 28 78 29 3b 0d 09 | 09 09 46 69 78 65 64 20 |ff(x);..|..Fixed | |00006230| 73 72 63 59 20 3d 20 66 | 66 28 79 29 3b 0d 09 09 |srcY = f|f(y);...| |00006240| 09 0d 09 09 09 4d 61 70 | 58 59 28 26 69 6e 76 65 |.....Map|XY(&inve| |00006250| 72 73 65 4d 61 70 70 69 | 6e 67 2c 20 26 73 72 63 |rseMappi|ng, &src| |00006260| 58 2c 20 26 73 72 63 59 | 29 3b 0d 09 09 09 69 66 |X, &srcY|);....if| |00006270| 20 28 47 65 74 46 72 61 | 63 74 69 6f 6e 61 6c 50 | (GetFra|ctionalP| |00006280| 69 78 65 6c 28 73 72 63 | 42 61 73 65 41 64 64 72 |ixel(src|BaseAddr| |00006290| 2c 20 73 72 63 52 6f 77 | 4c 6f 6e 67 73 2c 20 26 |, srcRow|Longs, &| |000062a0| 73 72 63 52 65 63 74 2c | 0d 09 09 09 09 09 73 72 |srcRect,|......sr| |000062b0| 63 58 2c 20 73 72 63 59 | 2c 20 64 73 74 41 64 64 |cX, srcY|, dstAdd| |000062c0| 72 2b 2b 29 20 26 26 20 | 6d 61 73 6b 57 6f 72 6c |r++) && |maskWorl| |000062d0| 64 29 0d 09 09 09 09 53 | 65 74 47 57 6f 72 6c 64 |d).....S|etGWorld| |000062e0| 50 69 78 65 6c 28 2a 6d | 61 73 6b 57 6f 72 6c 64 |Pixel(*m|askWorld| |000062f0| 2c 20 78 2c 20 79 29 3b | 0d 09 09 7d 0d 09 09 64 |, x, y);|...}...d| |00006300| 73 74 42 61 73 65 41 64 | 64 72 20 2b 3d 20 64 73 |stBaseAd|dr += ds| |00006310| 74 52 6f 77 4c 6f 6e 67 | 73 3b 0d 09 7d 0d 09 53 |tRowLong|s;..}..S| |00006320| 77 61 70 4d 4d 55 4d 6f | 64 65 28 26 6d 6d 75 4d |wapMMUMo|de(&mmuM| |00006330| 6f 64 65 29 3b 09 09 2f | 2a 20 52 65 73 74 6f 72 |ode);../|* Restor| |00006340| 65 20 74 68 65 20 70 72 | 65 76 69 6f 75 73 20 4d |e the pr|evious M| |00006350| 4d 55 20 6d 6f 64 65 2e | 20 2a 2f 0d 09 72 65 74 |MU mode.| */..ret| |00006360| 75 72 6e 20 64 73 74 57 | 6f 72 6c 64 3b 0d 7d 0d |urn dstW|orld;.}.| |00006370| 54 68 65 20 66 69 72 73 | 74 20 74 68 69 6e 67 20 |The firs|t thing | |00006380| 4d 61 70 47 57 6f 72 6c | 64 20 64 6f 65 73 20 69 |MapGWorl|d does i| |00006390| 73 20 63 61 6c 6c 20 4d | 61 70 52 65 63 74 61 6e |s call M|apRectan| |000063a0| 67 6c 65 2c 20 77 68 69 | 63 68 20 63 6f 6d 70 75 |gle, whi|ch compu| |000063b0| 74 65 73 20 74 68 65 20 | 73 69 7a 65 20 6f 66 20 |tes the |size of | |000063c0| 74 68 65 20 64 65 73 74 | 69 6e 61 74 69 6f 6e 20 |the dest|ination | |000063d0| 47 57 6f 72 6c 64 2e 20 | 28 54 68 69 73 20 61 6e |GWorld. |(This an| |000063e0| 64 20 6f 74 68 65 72 20 | 73 75 62 72 6f 75 74 69 |d other |subrouti| |000063f0| 6e 65 73 20 63 61 6e 20 | 62 65 20 66 6f 75 6e 64 |nes can |be found| +--------+-------------------------+-------------------------+--------+--------+ Only 25.0 KB of data is shown above.